n,q=map(int,input().split())
dl=[0]
pl=[0]
for i in range(n):
    d,p=map(int,input().split())
    dl.append(d)
    pl.append(p)
for i in range(q):
    j=int(input())
    d1 = [ i for i in dl if i<=j ]
    s=0
    for l in range(len(d1)):
        s=s+pl[l-1]
    if s<max(d1):
        print(s)
    else:
        print(max(d1))