#include <iostream>

using namespace std;

int main()
{
    int n, q, x=0;
    int* px=&x;
    unsigned long long s=0;
    cin>>n>>q;
    unsigned long long D[n], K[q];
    unsigned int P[n];
    cin>>D[0]>>P[0];
    for(int i=1;i<n;i++)
    {
        cin>>D[i]>>P[i];
        if(D[i-1]+P[i-1]>D[i])
        {
            D[i]=D[i-1]+P[i-1];
        }
    }
    for(int i=0;i<q;i++)
    {
        cin>>K[i];
        int j;
        for(j=x;K[i]>=D[j]&&j<n;j++)
        {
            if(K[i]>=D[j]+P[j])
            {
                s+=P[j];
                P[j]=0;
                *px=j+1;
            }
            else
            {
                s+=K[i]-D[j]+1;
                P[j]-=K[i]-D[j]+1;
                D[j]=K[i];
                *px=j;
            }
        }
        cout<<s<<"\n";
    }
    return 0;
}