HZNUOJ


Problem_ID: C
Result: Accepted
Time: 51ms
Memory: 25316kB
Author: 13777726382
In contest: 1296

x,y=map(int,input().split())
dic1={}
dic2={10:'A',9:'A',8:'B',7:'C',6:'OK'}
for i in range(x):
    n,m,s=input().split()
    dic1[n]=[n,int(s)]
    
for j in range(y):
    cj=dic1[input()][1]

    if cj<60:
        print("ARE YOU PIG?")
    else:
        print(dic2[cj//10])