#include <bits/stdc++.h>

using namespace std;

int main()
{
    std::ios::sync_with_stdio(false);
    int N, Q, p;
    long long int d, k, brpojela = 0LL, brima = 0LL;
    cin >> N >> Q;
    vector<long long int> dan(N, 0LL);
    vector<int> plz(N, 0);
    vector<long long int> pit(Q, 0LL);
    for(int i = 0; i < N; i++)
    {
        cin >> d >> p;
        dan[i] = d;
        plz[i] = p;
    }
    for(int i = 0; i < Q; i++)
    {
        cin >> k;
        pit[i] = k;
    }

    int i = 0, j = 0;
    while(true)
    {
        if(j >= Q)
            break;
        while(dan[i] <= pit[j] && i < N)
        {
            if(dan[i] == 1)
            {
                brima += plz[i];
                if(brima > 0)
                {
                    brima--;
                    brpojela++;
                }
            }
            else if(i > 0)
            {
                if(brima > dan[i] - dan[i-1] - 1)
                {
                    brima -= dan[i] - dan[i-1] - 1;
                    brpojela += dan[i] - dan[i-1] - 1;
                }
                else
                {
                    brpojela += brima;
                    brima = 0;
                }
                brima += plz[i];
                brima--;
                brpojela++;
            }
            else
            {
                brima += plz[i];
                if(brima > 0)
                {
                    brima--;
                    brpojela++;
                }
            }
            i++;
        }
        if(i > 0)
        {
            if(pit[j] - dan[i-1] > brima)
            {
                brpojela += brima;
                brima = 0;
            }
            else
            {
                brima -= pit[j] - dan[i-1];
                brpojela += pit[j] - dan[i-1];
            }
        }
        cout << brpojela << "\n";
        j++;
    }
    return 0;
}