Start: Apr, 17, 2017 10:00:00
Python程序设计基础培训第四次作业
End: Apr, 23, 2017 14:00:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 140ms
Memory: 21432kB
Author: 18958329966
In contest: 1088

def score(s):
	g=""
	if s>=90:
		g="A"
	elif s>=80:
		g="B"
	elif s>=70:
		g="C"
	elif s>=60:
		g="OK"
	else:
		g="ARE YOU PIG?"
	return g


x,y=map(int,raw_input().strip().split())
list1=[]
for i in range(x):
	rec=raw_input().strip().split()
	n,m,s=rec[0],rec[1],int(rec[2])
	list1.append([n,m,s])
list2=[]
for i in range(y):
	a=raw_input()
	list2.append(a)

for li2 in list2:
	for j in range(x):
		if li2==list1[j][0]:
			print(score(list1[j][2]))