#include <bits/stdc++.h>
using namespace std;
void resenje(vector<int>dani, vector<int>plazme,int krajnji_dan){
    int broj_plazmi=0;
    long long int res=0;
    int j=0;
    
    for (int i=0;i<krajnji_dan+1;i++){
        if (dani[j]==i){
            broj_plazmi=broj_plazmi+plazme[j];
            j++;
        }
        if (broj_plazmi>0){
            broj_plazmi--;
            res++;
        }
        
    }
    cout<<res<<endl;
}

int main() {
    int N,Q,b;
    long long int a,c;
    vector<int> dani;
    vector <int> plazme;
    cin>>N>>Q;
    for (int i=0;i<N;i++){
        cin>>a>>b;
        dani.push_back(a);
        plazme.push_back(b);
    }
    for (int i=0;i<Q;i++){
        cin>>c;
        resenje(dani,plazme,c);
    }
}