#include <bits/stdc++.h>
using namespace std;

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned long long int n, q;
    cin>>n>>q;
    unsigned long long int d[n+1], p[n];
    for(unsigned long long int i = 0; i < n; i++){
        cin>>d[i]>>p[i];
    }

    unsigned long long int k[q];
    for(unsigned long long int i = 0; i < q; i++){
        cin>>k[i];
    }
    unsigned long long int j = 0, po = 0, da = 0, nr= 0, pop=0;
    unsigned long long int res[q];
    for(unsigned long long int i = 0; i < q; i++){
        while(da<=k[i]){
            pop=po;
            if(k[i]<d[0])
                break;
            if(j==n+1){
                break;
            }
            if (k[i]>d[j] ){
                if(j<n){
                    nr +=p[j];
                    if(da<d[j])
                        da=d[j];
                }
                j++;
            }

            if(k[i]>(nr+da-1)){
                po+=nr;
                da+=nr;
                nr=0;
            }
            else{
                po+=k[i]-da+1;
                nr-=k[i]-da+1;
                da=k[i]+1;
            }
            if(po==pop)
                break;
        }
        res[i]=po;

    }
    for(unsigned long long int i = 0; i < q; i++){
        cout<<res[i]<<"\n";
    }
    return 0;

}