#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, q; cin >> n >> q;
    int attcnt = 0;
    vector<int> att(n), poi(n);
    for(int i = 0; i < n; ++i)
        {cin >> att[i] >> poi[i]; if(att[i]) attcnt++;}
    vector<int> prefdag(n), prefpoi(n);
    prefdag[0] = att[0];
    for(int i = 1; i < n; ++i)
        prefdag[i] = prefdag[i - 1] + att[i];
    prefpoi[0] = poi[0]; int cur = poi[0];
    for(int i = 1; i < n; ++i){
        cur += poi[i];
        prefpoi[i] = prefpoi[i - 1] + cur;
    }
    while(q--){
        int h; cin >> h;
        if(attcnt){
            if(prefdag[n - 1] < h)
                cout << -1;
            else
                cout << lower_bound(prefdag.begin(), prefdag.end(), h) - prefdag.begin() + 1 << '\n';
        } else {
            if(prefpoi[n - 1] < h)
                cout << -1;
            else
                cout << lower_bound(prefpoi.begin(), prefpoi.end(), h) - prefpoi.begin() + 1 << '\n';
        }
    }
    return 0;
}