#The solution in Python 3 is as follows:
import sys
while 1:
a, b, c = map(int,sys.stdin.readline().split())
if a == 0 and b == 0 and c == 0:
break
elif b - a == c - b:
print ("AP", c + (b - a)) #next term for AP sequences
elif b/a == c/b:
print ("GP", c * (b//a)) #next term for GP sequences
#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!
import sys
while 1:
a, b, c = map(int,sys.stdin.readline().split())
if a == 0 and b == 0 and c == 0:
break
elif b - a == c - b:
print ("AP", c + (b - a)) #next term for AP sequences
elif b/a == c/b:
print ("GP", c * (b//a)) #next term for GP sequences
#Keep visiting for more solutions of SPOJ problems in Python 3.Thank you!!!