#include <bits/stdc++.h>
#define ll long long
#define maxn 300100
using namespace std;
ll ps[maxn];
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    ll n, q; cin >> n >> q;
    ll d[n+10], p[n+10], k[q+10];
    ps[0]=0;
    for (ll i=1; i<=n; i++){
        cin >> d[i] >> p[i];
        ps[i]=ps[i-1]+p[i];
    }
    for (ll i=1; i<=q; i++) cin >> k[i];
    for (ll i=1; i<=q; i++){
        ll l=1, r=n, m, ans=-1;
        while (l<=r){
            m=l+(r-l)/2;
            if (d[m]<=k[i]){
                ans=m;
                l=m+1;
                continue;
            }
            r=m-1;
        }
        if (ans==-1) {cout << 0 << '\n'; continue;}
        ll br=ps[ans], pom=(d[ans]+p[ans]-1);
        if (pom>k[i]) br-=(pom-k[i]);
        cout << br << '\n';
    }
    return 0;
}