#include <iostream>
#include <vector>

using namespace std;

int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int brPoteza;
    int brSefova;
    cin >> brPoteza;
    cin >> brSefova;

    vector<int> hp(brSefova,0);
    vector<pair<int,int>> dmg;
    for(int i = 0;i < brPoteza;i++){
        int udarac;
        int otrov;
        cin >> udarac;
        cin >> otrov;
        dmg.push_back(make_pair(udarac,otrov));
    }
    for(int i = 0;i < brSefova;i++){
        cin >> hp[i];
    }
    for(int i = 0;i < brSefova;i++){
    int high = brPoteza;
    int low = 0;
    int mid = int((high + low + 1) / 2);
    int lowestRound = -1;
    bool leave = false;
    while(low != high){
        if(abs(low - high) == 1){
            leave = true;
        }
        int currHp = hp[i];
        int currRound = 0;
        for(int j = 0;j < mid;j++){
            if(dmg[j].second * (mid - j) > dmg[j].first){
                currHp -= dmg[j].second * (mid - j);
            }
            else{
                currHp -= dmg[j].first;
            }
            if(currHp <= 0){
                high = mid;
                lowestRound = mid;
                mid = int((mid + low + 1) / 2);
                break;
            }
        }
        if(currHp > 0){
            low = mid;
            mid = int((mid + high + 1) / 2);
        }
        if(leave){
            break;
        }
    }
    if(lowestRound > -1){
        cout << lowestRound << " ";
    }
    else{
        cout << "-1 ";
    }
    }
    return 0;
}