import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) a,b = list(map(int, input().split())) n = 20 dp = [[0]*n for _ in range(n)] for i in range(n): for j in range(n): if i==j==0: continue ok = 0 for k in range(1,i+1): if i-k==j: continue if dp[i-k][j]==0: ok = 1 # print(i,i-k,j) for k in range(1,j+1): if j-k==i: continue if dp[i][j-k]==0: ok = 1 dp[i][j] = ok if a==b: if a%2==0: ans = "Q" else: ans = "P" elif abs(a-b)==1: v = min(a,b) if v%2==0: ans = "Q" else: ans = "P" else: ans = "P" print(ans)