#include<iostream>
#include<algorithm>
using namespace std;

const int MAX_N=300000;

long long dani[MAX_N];
long long pak[MAX_N];
long long pr_sum[MAX_N];

int main() {
    int N, Q;
    cin>>N>>Q;

    for(int i=0;i<N;++i) 
    {
        cin>>dani[i]>>pak[i];
        pr_sum[i]=pak[i]+(i>0?pr_sum[i- 1]:0);
    }

    for(int q=0;q<Q;++q) 
    {
        long long k;
        cin>>k;

        int nis=0,vis=N- 1,i=-1;
        while(nis<=vis) 
        {
            int sred=(nis+vis)/2;
            if(dani[sred]<=k) 
            {
                i=sred;
                nis=sred+1;
            } 
            else 
            {
                vis=sred- 1;
            }
        }

        if(i==-1||k<dani[0]) 
        {
            cout<<0<<endl;
        } 
        else 
        {
            long long uk_dani=k-dani[0]+ 1;
            long long dos=pr_sum[i];
            long long po=min(dos,uk_dani);
            cout<<po<<endl;
        }
    }
    return 0;
}