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

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];
    }

    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;
                }

        }

    }
    bool found;
    for(int i = 0;i < brSefova;i++){
            found = false;
        for(int j = 0;j < brPoteza;j++){
            if(dmgpround[j] >= hp[i]){
                found = true;
                cout << j + 1 << " ";
                break;
            }
        }
        if(found == false){
            cout << "-1 ";
        }
    }
    return 0;
}