#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;
vector<int> hp(200000,0);
bool myFunc(int i,int j){
    return hp[i] < hp[j];
}
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int brPoteza;
    int brSefova;
    cin >> brPoteza;
    cin >> brSefova;

    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];
    }
    vector<int> ind;
    for(int i =0;i < brSefova;i++){
        ind.push_back(i);
    }
    vector<int> res(brSefova,0);
    vector<int> dmgpround(brPoteza,0);
    for(int i = 0;i < brPoteza;i++){
        int d = 0;
        if(dmg[i].second > 0){
        d = floor(double(dmg[i].first) / dmg[i].second);}
        else{
            d = -1;
        }
        for(int j = i;j < brPoteza;j++){
                if(j - i >= d && d != -1){
            dmgpround[j] += dmg[i].second * (j - i + 1);
                }
                else{
                    dmgpround[j] += dmg[i].first;
                }

        }

    }
    sort(ind.begin(),ind.end(),myFunc);
    bool found;
    int startfrom = 0;
    for(int i = 0;i < brSefova;i++){
            found = false;
        for(int j = startfrom;j < brPoteza;j++){
            if(dmgpround[j] >= hp[i]){
                found = true;
                res[ind[i]] = j + 1;
                startfrom = j;
                break;
            }
        }
        if(found == false){
            res[i] = -1;
        }
    }
            for(auto a:res){
            cout << a << " ";
        }
    return 0;
}