import sys input = sys.stdin.readline A,B=map(int,input().split()) if A>B: A,B=B,A if (A,B) in [(1,1),(1,2),(3,3)] or (A>=3 and B==A+1): print("Q") else: print("P")