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