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

long long main ()
{
    long long n_moves, n_bosses;
    vector<long long> normal, poison;
    long long mult=0;
    bool normalZero = true;
    bool poisonZero = true;
    cin >> n_moves >> n_bosses;
    for(long long movex=0; movex<n_moves; movex++)
    {
        long long t1, t2;
        cin >> t1 >> t2;
        normal.push_back(t1);
        poison.push_back(t2);
        if(t1 != 0)
            normalZero = false;
        if(t2 != 0)
            poisonZero = false;

    }
    if(poisonZero)
    {

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


            }
            if(!broken)
                cout << k << endl;
        }
    }


    return 0;
}