#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,q;
    cin >> n >> q;
    ll d[n],p[n],k;
    ll uk;
    for(ll i=0;i<n;i++) {
        cin >> d[i];
        cin >> p[i];
    }
    for(ll i=0;i<q;i++)
    {
        uk=0;
        cin >> k;
    for(ll i=0;i<n;i++)
    {
        if(k<d[i]) {
            break;
        }
        uk+=min(k-d[i]+1,p[i]);
    }
        cout << uk << endl;
        }


    return 0;
}