#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define cy cout << "YES" << endl;
#define cn cout << "NO" << endl;
#define pf push_front
#define pb push_back
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vll vector<ll>
#define print(x) cout << x << endl;
#define prints(x) cout << x << ' ';


void solve()
{
    int n,q; cin >> n >> q;
    vi dk(n),pk(n);
    ll sumDk = 0, sumPk = 0;
    
    for(int i = 0; i < n; i++)
    {
        cin >> dk[i] >> pk[i];
        sumDk += dk[i];
        sumPk += pk[i];
    }

    
    if(sumPk == 0)
    for(int i = 0;  i< q; i++)
    {
        int q; cin >> q;
        for(int j = 0; j < n; j++)
        {
            q -= dk[j];
            if(q < 0)
            {
                cout << j+1 << '\n';
                continue;
            }
        }
        if(q < 0)
            cout << "-1" << '\n';
    }



}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int tt= 1;
    while(tt--)
    {
        solve();
    }
}