#include <bits/stdc++.h>
#define pb push_back
#define int long long

using namespace std;

vector<pair<int , int>>v1;
int n;

map <int , int> mapa;

bool moguce(int & mid , int & p){
    if (mapa[mid] != 0){
        return mapa[mid] >= p;
    }

    int res = 0;
    for (int i = 0; i<mid && i<v1.size()-1; i++){
        res += max(v1[i].first , v1[i].second*mid);
    }
    mapa[mid] = res;
    return res >= p;
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int q , x , y;
    bool x0 = true , y0 = true;
    cin>>n>>q;
    for (int i = 0; i<n; i++){
        cin>>x>>y;
        if (x != 0){
            x0 = false;
        }
        if (y != 0){
            y0 = false;
        }
        v1.pb(make_pair(x , y));
    }

    for (int i = 0; i<q; i++){
        cin>>x;
        int mid , l = 1 , r = n+1;

        while (l<r){
            mid = (l+r)/2;
            if (moguce(mid , x)){
                r = mid;
            }else {
                l = mid+1;
            }
        }
        if (!moguce(n , x)){
            cout<<"-1\n";
        }else {
            cout<<r<<"\n";
        }
    }



    return 0;
}