#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll INF=numeric_limits<ll>::max();


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n,t;
    cin>>n>>t;
    vector<ll> d(n);
    vector<ll> p(n);
    for(ll i=0;i<n;i++)cin>>d[i]>>p[i];
    vector<ll> q(t);
    for(ll i=0;i<t;i++)cin>>q[i];
    vector< vector<ll> > v(n);

    for(ll i=0;i<n;i++)v[i].resize(0);

    for(ll i=0;i<n;i++){
        if(p[i]==0)continue;

        ll x=max(d[i]-1,(long long)0)/p[i];
        if(i+x-(ll)1>=n)continue;

        v[i+x].push_back(i);


    }

    ll sump=0;
    /*
    for(ll i=0;i<n;i++){
        for(ll j=0;j<v[i].size();j++)cout<<v[i][j]<<' ';
        cout<<endl;
    }*/
    vector<ll> ans(n+1,0);
    for(ll i=1;i<n+1;i++){
        ans[i]=ans[i-1]+d[i-1]+sump;
        for (ll j=0;j<v[i-1].size();j++){
            ll x=v[i-1][j];
            ans[i]-=d[x];
            ans[i]+=(i-x)*p[x];
            sump+=p[x];
        }
    }/*
    for(ll i=0;i<n+1;i++)cout<<ans[i]<<' ';
    cout<<endl;*/
    for(ll i=0;i<t;i++){

        if(lower_bound(ans.begin(),ans.end(),q[i])==ans.end())cout<<-1<<endl;
        else {
            cout<<distance(ans.begin(),lower_bound(ans.begin(),ans.end(),q[i]))<<endl;
        }
    }


    return 0;
}