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

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

    }


        long long n_tries=1;
        for(int i=0; i<n_moves; i++)
        {
            n_tries *= 2;
        }

        for(int boss=0; boss<n_bosses; boss++)
        {
            int health;
            cin >> health;

            long long min=-1;
            bool minexists=false;
            for(long long t=1; t<=n_tries; t++)
            {
                int health1 = health;
                long long c;
                long long add = 0;
                // at bit 1 data for move 1 is stored.  1 is poison, 0 is normal.
                int k;
                for(k=0; k<n_moves; k++)
                {
               //     cout << "Health before " << k << " move is " << health1 << endl;
                    int type = (t/((int)(pow(2, k))))%2;
                    if(type == 1)
                    {
                        health1 -= poison[k] + add;
                        add+=poison[k];
                    } else
                        health1 -= normal[k] + add;

                    if(health1 <= 0)
                        break;
                }
            //    cout << "Health at the end: " << health1 << endl;

                if(health1 > 0)
                    c = -1;
                else {
                    if(!minexists){
                        min = k+1;
                        minexists = true;
                    } else {
                        c = k+1;
                        if(c < min) min = c;
                    }
                }


            }
            cout << min << endl;

  //      }
    }
    return 0;
}