#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;
        for (int j=0;j<n;j++)
        {
            if (k<d[j]) break;
            odg+=min(k-d[j]+1,p[j]);
        }
        cout<<odg<<'\n';
    }
}