while 1:t=raw_input();print t+" %sM"%"AP"[t>'12']*('01'