# 19637번. IF문 좀 대신 써줘
importsysinput=sys.stdin.readline# 다시 풀어볼 문제...
n,m=map(int,input().split())cost=[]# 전투력 관리
name=[]# 칭호만 관리
foriinrange(n):a,b=input().rstrip().split()cost.append(int(b))name.append(a)i=0whilei<len(cost)-1:ifcost[i]==cost[i+1]:cost.pop(i+1)name.pop(i+1)i+=1t=[]foriinrange(m):t.append([int(input()),i,0])t.sort()foriinrange(len(cost)):ift[0][0]<=cost[i]:t[0][2]=name[i]idx=ibreakforiinrange(m):ift[i][0]<=cost[idx]:t[i][2]=name[idx]else:idx+=1whileTrue:ift[i][0]<=cost[idx]:t[i][2]=name[idx]breakidx+=1ans=[0foriinrange(m)]foriinrange(m):ans[t[i][1]]=t[i][2]foriinrange(m):print(ans[i])