#include <iostream>

using namespace std;

int main()
{
    unsigned long long int n,q,brojac=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[nizq[q-1]],broj=nizq[q-1];
    for(unsigned long long int i=0;i<broj;i++){
        if(i+1==nizn[brojac]){
            plazma+=nizp[brojac];
            brojac++;
        }
        if(plazma>0){
            if(i==0){
                resenja[0]=1;
                plazma--;
            }
            else{
                resenja[i]=resenja[i-1]+1;
                plazma--;
            }
        }else{
            if(i==0)
                resenja[0]=0;
            else
                resenja[i]=resenja[i-1];
        }

    }
    for(unsigned long long int i=0;i<q;i++){
        cout<<resenja[nizq[i]-1];
    }
    return 0;
}