#include <iostream>
#include <queue>

int main() {
    int n , q, i, j,brh = 0;
    cin >> n >> q;
    int H[q];
    int d[n], p[n];
    for(i = 0; i < n; i++) {
        cin >> d[i] >> p[i];
    }
    int brn=n;
    int sd = 0;
    int ps = 0;
    queue<int> hits;
    for(i = 0; i < q; i++) {
        cin >> H[i];
        for(j = 0; j < n; j++){
            if(d[j] == 0) {
                ps+=p[j];
            }
            else if(p[j] == 0) {
                H[i] -= d[j];
            }
            H[i] -= ps;
            brh++;
            if(H[i] <= 0) {
                hits.push(brh);
                brh = 0;
                ps = 0;
                break;
            }
        }
    }
    while(!hits.empty()){
        cout << hits.front() << endl;
        hits.pop();
    }
}