#include <iostream>

using namespace std;
typedef unsigned long long int ulli;

int main()
{
    int n,q;
    cin>>n>>q;
    ulli d[n],p[n],k;
    for (int i=0;i<n;i++)
    {
        cin>>d[i]>>p[i];
    }
    for (int i=0;i<q;i++)
    {
        cin>>k;
        ulli odg=0,zalihe=p[0];
        int trenIndexDanaKupovine=0;
        for (ulli j=d[0]-1;j<k;)
        {
            if (zalihe==0)
            {
                if (trenIndexDanaKupovine==n-1)
                    break;
                else{
                    j=d[++trenIndexDanaKupovine]-1;
                    zalihe+=p[trenIndexDanaKupovine];
                }
            }
            else if(zalihe>k-j)
            {
                odg+=k-j;
                break;
            }
            else
            {
                odg+=zalihe;
                zalihe=0;
                j++;
            }
        }
        cout<<odg<<'\n';
    }
}