#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...);}
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 2e5 + 3;
ll d[N], p[N], sumd[N], sumS[N], sump[N];
bool sigurno[N];


void solve() {
    int n, q; cin >> n >> q;
    bool dnula = true, pnula = true;
    for (int i = 1; i <= n; i++) {
        cin >> d[i] >> p[i];
        if (d[i] != 0)
            dnula = false;
        if (p[i] != 0)
            pnula = false;
        sumd[i] = sumd[i-1] + d[i];
        sumS[i] = sumS[i-1] + p[i];
        sump[i] = sump[i-1] + sumS[i];
        if (sigurno[i-1])
            sigurno[i] = true;
        else if (sump[i] > 1e9)
            sigurno[i] = true;
    }
    //dbg(dnula, pnula);
    while (q--) {
        int h; cin >> h;
        int low = 1, high = n+1;
        while (low < high) {
            int mid = (low + high) / 2;
            if (pnula) {
                if (sumd[mid] >= h) {
                    high = mid;
                } else
                    low = mid+1;
            } else if (dnula) {
                if (sigurno[mid] || sump[mid] >= h) {
                    high = mid;
                } else
                    low = mid+1;
            } else {
                if (sigurno[mid] || (simp[mid] - p[mid] + max(p[mid], d[mid])) >= h) {
                    high = mid;
                } else
                    low = mid+1;
            }
        }
        if (low == n+1)
            low = -1;
        cout << low << "\n";
    }
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int t=1; //cin >> t;
    while (t--) {
        solve();
    }
}