#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n, q;
    cin>>n>>q;
    vector <ll> d(n), pref(n), br(n);
    for (int i=0; i<n; i++)
    {
        cin>>d[i];
        ll p;
        cin>>p;
        pref[i]=max(d[i]-1, pref[i-1]*(i>0))+p;
        br[i]=br[i-1]*(i>0)+min(pref[i-1]*(i>0)-d[i]+1, 0LL);
    }
    /*for (auto i: pref) cout<<i<<" ";
    cout<<endl;
    for (auto i: br) cout<<i<<" ";
    cout<<endl;*/
    while (q--)
    {
        ll k;
        cin>>k;
        ll up=upper_bound(d.begin(), d.end(), k)-d.begin()-1;
        if (upper_bound(d.begin(), d.end(), k)==d.end()) up=n-1;
        if (up==-1) cout<<0<<endl;
        else
        {
            if (upper_bound(d.begin(), d.end(), k)==d.end()) up=n-1;
            cout<<min(pref[up], k)+br[up]<<endl;
        }
    }
    return 0;
}