# 19637번. IF문 좀 대신 써줘
importsysinput=sys.stdin.readlinen,m=map(int,input().split())powerList=[]nameList=[]foriinrange(n):name,power=input().split()power=int(power)ifpowerListandpowerList[-1]==power:# 가장 처음 칭호만 저장해주기 위해
continuepowerList.append(power)nameList.append(name)defbinary_search(p):left=0right=len(powerList)-1whileleft<=right:mid=(left+right)//2ifp>powerList[mid]:left=mid+1else:right=mid-1print(nameList[right+1])mList=[]for_inrange(m):p=int(input())binary_search(p)# 이분탐색