#include <bits/stdc++.h>
#define ll long

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    int d[n];
    int x;
    int s =0;
    for(int i = 0; i < n;i++)
    {
        int d1;
        s+=d1;
        cin >> d1 >> x;
        d[i] = d1;
    }
    for(int i = 0; i < q;i++)
    {
        int h;
        cin >> h;
        if(h - s > 0)
        {
            cout << -1 << "\n";break;
        }
        for(int j = 0;j < n;j++)
        {
            h-=d[j];
            if(h <= 0)
            {
                cout << j+1<< "\n";break;
            }
        }
        if(h > 0) cout << -1<< "\n";
    }
}