#include <iostream>

using namespace std;

int main()
{
    unsigned long long int n,q,brojac1=0,brojac2=0,plazma=0;
    cin>>n>>q;
    unsigned long long int nizn[n],nizp[n],nizq[q];
    for(unsigned long long int i=0;i<n;i++){
        cin>>nizn[i];
        cin>>nizp[i];

    }
    for(unsigned long long int i=0;i<q;i++){
        cin>>nizq[i];
    }
    unsigned long long int resenja=0,broj=nizq[q-1];
    for(unsigned long long int i=0;i<broj;i++){
        if(i+1==nizn[brojac1]){
            plazma+=nizp[brojac1];
            brojac1++;
        }
        if(plazma>0){
                resenja+=1;
                plazma--;
        }
        if(i+1==nizq[brojac2]){
            cout<<resenja<<endl;
            brojac2++;
            if(q==brojac2){
                break;
            }
        }

    }
    return 0;
}