#include<bits/stdc++.h>
using namespace std;
int n,q;
long long d[200050], p[200050];
unsigned long long prefsum[200050];
int mini, maks, sred;
bool pr;

int main ()
{
    scanf("%d %d", &n, &q);
    for(int i=1; i<=n; i++)
    {
        scanf("%lld %lld", &d[i], &p[i]);
        prefsum[i] = prefsum[i-1] + d[i];
    }
    for(int i=1; i<=q; i++)
    {
        long long h;
        scanf("%lld", &h);
        if(prefsum[n] < h)
            printf("-1 \n");
        else
        {
            mini = 1;
            maks = n;
            sred = 0;
            while(mini <= maks)
            {
                sred = (mini+maks)/2;
                if(prefsum[sred] >= h and prefsum[sred-1] < h)
                    printf("%d \n", sred);
                if(prefsum[sred] >= h)
                    maks = sred-1;
                if(prefsum[sred] < h)
                    mini = sred+1;
            }
        }
    }
    return 0;
}
/*
3 5
3 0
4 0
5 0
3
4
5
13
2

*/