#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define rep(i,a,b) for(int i=a; i<b;i++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,q;
    cin>>n>>q;
    vll d(n), p(n), prefSuma(n);
    rep(i,0,n){cin>>d[i]>>p[i];}
    prefSuma[0]=p[0];
    rep(i,1,n){prefSuma[i]=prefSuma[i-1]+p[i];}
    while (q--) {
        ll k;
        cin>>k;
        int dx=upper_bound(d.begin(),d.end(),k)-d.begin()-1;
        if(dx==-1) cout<<"0\n";
        else {
            ll uplazma=prefSuma[dx];
            ll dani=k-d[0]+1;
            uplazma=min(uplazma,dani);
            cout<<uplazma<<"\n";
        }
    }
    return 0;
}