#include <iostream>
#include <algorithm>
using namespace std;
// final frfr?
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    int d[n], p[n];
    int group = 0;
    for (int i=0; i<n; i++) {
        scanf("%d %d", &d[i], &p[i]);
        if (d[i] == 0) group = 2;
        else if (p[i] == 0) group = 1;
    }
    int h[q];
    for (int i=0; i<q; i++) {
        scanf("%d", &h[i]);
    }
    
    if (group == 1) {
        int sumd[n];
        sumd[0] = d[0];
        for (int i=1; i<n; i++) sumd[i] = sumd[i-1] + d[i];

        for (auto cap : h) {
            auto it = lower_bound(sumd, sumd+n, cap)-sumd;
            if (sumd[it] >= cap) cout << it+1 << endl;
            else printf("-1\n");
        }
    } else if (group == 2) {
        int prefd[n], sumd[n];
        prefd[0] = d[0];
        for (int i=1; i<n; i++) prefd[i] = prefd[i-1] + d[i];
        sumd[0] = d[0];
        for (int i=1; i<n; i++) sumd[i] = sumd[i-1] + prefd[i];
        
        for (auto cap : h) {
            auto it = lower_bound(sumd, sumd+n, cap)-sumd;
            if (sumd[it] >= cap) cout << it+1 << endl;
            else printf("-1\n");
        }
    } else printf("nzm");

    return 0;
}
/*
6 15
2 0
4 0
0 0
0 0
3 0
5 0
1 2 3 4 5 6 7 8 9 10 11 13 14 15 16
*/











/*
7 13
4 0
1 0 0 0
5 0
3 0
3 0
7 0
2 5 6 11 17 13 16 21 17 23 30 24 4
*/









/*
6 4
2 0
3 0
1 0
5 0
3 0
4 0
20
14
16
7
*/