#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int q;
    cin >> n;
    cin >> q;
    long long dani[n];
    long long pakovanja[n];
    for (int i = 0; i < n; ++i){
        cin >> dani[i];
        cin >> pakovanja[i];
    }

    long long up;
    long long k;
    long long sum;
    long long br;
    for (int i = 0; i < q; ++i){
        cin >> k;
        br=0;
        up= 0;
        sum = 0;
        for (int j = 1; j <= k; ++j){
            if (br<n && j == dani[br]){
                up+=pakovanja[br];
                br++;
            }
            if (up>0){
                sum++;
                up--;
            }
            if (n<=br && up==0){
                
            }
        }
        cout <<sum<<endl;
    }
}