#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);
int n,q;
cin>>n>>q;
vector<int>d(n+1);
vector<int>p(n+1);
vector<int>prefp(n+1);
vector<int>krajd(n+1);
for(int i = 1;i<=n;i++){
cin>>d[i]>>p[i];
}
prefp[1]=p[0];
for(int i = 1;i<=n;i++)
    prefp[i]=prefp[i-1]+p[i];
krajd[0]=d[1];
for(int i = 1;i<=n;i++){
    krajd[i]=p[i]+max(krajd[i-1],d[i]);

}
int help=0;
for(int i = 0;i<q;i++){
int x;
cin>>x;
for(int j = help;j<=n+1;j++){
    if(krajd[j]>x&&j>=1){
        int delta=min(x-krajd[j-1]-d[j-1]+krajd[j-1]+1,p[j]);
        cout<<delta+prefp[j-1]<<endl;
        help=j;
        break;
    }
    if(krajd[j]>x&&j==0){
            help=j;
        cout<<0<<endl;
        break;
    }
    if(j==n+1){
            help=j;
cout<<prefp[n]<<endl;
        break;
    }
}





}
return 0;
}