#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] + a[i];
        
        for (auto cap : h) {
            auto it = upper_bound(sumd, sumd+n, cap)-sumd+n;
            if (sumd[it] >= cap) printf("%d\n", it);
            else printf("-1\n");
        }
    }

    return 0;
}