#include<iostream>
#include<vector>
using namespace std;

int main ()
{
    long long n_moves, n_bosses;
    vector<long long> normal, poison, moves;
    cin >> n_moves >> n_bosses;

    for(long long i=0; i<n_moves; i++)
    {
        long long t1, t2;
        cin >> t1 >> t2;
        normal.push_back(t1);
    }

    for(long long i=0; i<n_bosses; i++)
    {
        long long health;
        cin >> health;
        int move = 0;
        bool broken = false;
        while(health > 0)
        {
            if(move >= n_moves){
                cout << -1 << endl;
                broken = true;
                break;
            }
            health -= normal[move];
            move++;
        }

        if(!broken)
            cout << move << endl;

    }
    
    cout << " " << endl;


    return 0;
}