HZNUOJ


Problem_ID: C
Result: Accepted
Time: 46ms
Memory: 25184kB
Author: 2018212212087
In contest: 1300

x,y=map(int,input().split())
level={10:"A",9:"A",8:"B",7:"C",6:"OK"}
a={}
for i in range(x):
	s=input().split()
	a[s[0]]=[s[1],int(s[2])]
for j in range(y):
	cj=a[input()][1]
	if cj<60:
		print("ARE YOU PIG?")
	else:
		print(level[cj//10])