#include <bits/stdc++.h>

using namespace std;

int N,Q;
vector<long long> d, p;
vector<long long> k;

long long odgovor(long long brojpitanja) {
    long long brojPlazme = 0;
    long long dan = 0;
    long long brojOdg = 0;
    for(long long i=0; i<brojpitanja; i++) {
        //cout<<"--------------------"<<endl;
        if(i+1==d[dan]) {
            brojPlazme=brojPlazme+p[dan];
            dan++;
            //cout<<"Dan povecan!"<<endl;
        }
        if(brojPlazme>0) {
            brojPlazme--;
            brojOdg++;
            //cout<<"plazma pojedena - brojODG povecan"<<endl;
        }

        //cout<<"i: "<<i<<endl;
        //cout<<"dan: "<<dan<<endl;
        //cout<<"brojPlazme: "<<brojPlazme<<endl;
        //cout<<"brojOdg: "<<brojOdg<<endl;
    }

    return brojOdg;
}

int main() {
    cin >> N >> Q;
    for(int i=0; i<N; i++) {
        long long tempd, tempp;
        cin >> tempd >> tempp;
        d.push_back(tempd);
        p.push_back(tempp);
    }
    for(int i=0; i<Q; i++) {
        long long tempk;
        cin >> tempk;
        k.push_back(tempk);
    }

    for(int i=0; i<Q; i++)
    cout << odgovor(k[i]) << endl;

    return 0;
}