#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using str = string;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
#define f first
#define s second
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define sor(x) sort(all(x))
#define lb lower_bound
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

void solve(){
    int n, q;
    cin >> n >> q;
    vl d(n + 1), p(n + 1), h(q);
    F0R(i, n) cin >> d[i + 1] >> p[i + 1];
    F0R(i, q)cin >> h[i];
    vl prefd(n + 1);
    FOR(i, 1, n + 1)prefd[i] = prefd[i - 1] + d[i];
    vpl change(n + 1);
    FOR(i, 1, n + 1) {
        if(p[i] == 0)change[i] = {n + 1, i};
        else change[i] = {i + (d[i] - 1) / p[i], i};
    }
    sor(change);
    vl mind(n + 1), prefp(n + 1), sol(n + 1);
    ll curp = 0;
    int j = 1;
    FOR(i, 1, n + 1){
        mind[i] = mind[i - 1];
        prefp[i] = prefp[i - 1];
        while(j <= n && change[j].f <= i){
            mind[i] += d[change[j].s];
            curp += p[change[j].s];
            prefp[i] += (change[j].f - change[j].s) * p[change[j].s];
            j++;
        }
        prefp[i] += curp;
        sol[i] = prefd[i] - mind[i] + prefp[i];
    }
    /*trav(el, prefd)cout << el << " ";
    cout << "\n";
    trav(el, mind)cout << el << " ";
    cout << "\n";
    trav(el, prefp)cout << el << " ";
    cout << "\n";
    trav(el, sol)cout << el << " ";
    cout << "\n";*/
    F0R(i, q){
        int pos = lb(all(sol), h[i]) - bg(sol);
        if(pos == n + 1)cout << -1 << "\n";
        else cout << pos << "\n";
    }
}


int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t; t = 1;while(t--){
        solve();
    }
    return 0;
}