program x;

var n,q,j,l:integer;
    d,k:array[1..300000] of longint;
    p:array[1..300000] of integer;
    ps,pe,i:longint;

begin
    read(n,q);
    for i:=1 to n do read(d[i],p[i]);
    for i:=1 to q do read(k[i]);
    for l:=1 to q do begin
        ps:=0;
        pe:=0;
        j:=1;
        for i:=1 to k[l] do begin
            if i=d[j] then begin
                ps:=ps+p[j];
                j:=j+1;
            end;
            if ps<>0 then begin
                ps:=ps-1;
                pe:=pe+1;
            end;
        end;
        writeln(pe);
    end;
end.