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

int main() {
    int n, q;
    cin>>n>>q;
    vector<int> d(n);
    vector<int> p(n);
    vector<int> h(q);
    int o = 0;
    int e = 0;
    for(int i = 0; i < n; i++){
        cin>>d[i]>>p[i];
        if(p[i] > 0){
            o++;
        }
        if(d[i] > 0){
            e++;
        }
    }
    for(int i = 0; i < q; i++){
        cin>>h[i];
    }
    if(e == 0){
        for(int j = 0; j < q; j++){
            int r = 0;
            bool b = false;
        for(int i = 0; i < n; i++){
            h[j] = h[j] - p[i] - r;
            r += p[i];
            if(h[j] <= 0){
                cout<<i<<endl;
                b = true;
                break;
            }
        }
        if(!b){
            cout<<"-1"<<endl;
        }
        }
    }
    else
    if(o == 0){
        for(int j = 0; j < q; j++){
            bool b = false;
        for(int i = 0; i < n; i++){
            h[j] = h[j] - d[i];
            if(h[j] <= 0){
                cout<<i<<endl;
                b = true;
                break;
            }
        }
        if(!b){
            cout<<"-1"<<endl;
        }
        }
    }
    else{
        for(int j = 0; j < q; j++){
            int r = 0;
            bool b = false;
        for(int i = 0; i < n; i++){
            if(h[j] >= r + d[i]){
                h[j] = h[j] - r - p[i];
                r += p[i];
            }
            else{
                h[j] = h[j] - r - d[i];
            }
            if(h[j] <= 0){
                cout<<i<<endl;
                b = true;
                break;
            }
        }
        if(!b){
            cout<<"-1"<<endl;
        }
        }
    }
}