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

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 == 0) printf("nzm");
    else 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) printf("%d\n", it+1);
            else printf("-1\n");
        }
    }

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