Start: Jul, 06, 2019 10:00:00
20190706Python程序设计基础培训扩展练习
End: Jul, 17, 2019 12:00:00
Time elapsed:
Time remaining:

Problem_ID: C
Result: Accepted
Time: 53ms
Memory: 25320kB
Author: 13185217161
In contest: 1300

x,y=map(int,input().split())
xs=[]
d1={10:"A",9:"A",8:"B",7:"C",6:"OK",5:"ARE YOU PIG?"}
for i in range(x):
    a,b,c=map(str,input().split())
    c=int(c)
    xs.append([a,b,c])

for j in range(y):
    a=input()
    for k in range(len(xs)):
        if a==xs[k][0]:
            # print(xs[k][2])
            d=5 if xs[k][2]//10<=5 else xs[k][2]//10
            print(d1[d])