#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    cin.tie(0);cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    int d[n];
    int p[n];
    int h[q];
    bool alld = true;
    bool allp = true;
    for(int i = 0; i < n; i++)
    {
        ll d1;ll p1;
        cin >> d1 >> p1;
        if(d1 != 0) allp = false;
        if(p1 != 0) alld = false;
        d[i] = d1; p[i] = p1;
    }
    for(int i = 0; i < q;i++)
    {
        cin >> h[i];
    }
    for(int i = 0; i < q;i++)
    {
        if(alld)
        {
            for(int j = 0; j < n;j++)
            {
                h[i]-=d[j];
                if(h[i] <= 0)
                {
                    cout << j+1 << "\n";break;
                }
                if(j==n-1 && h[i] > 0) cout << -1 << "\n";
            }
        }
        else if(allp)
        {
            int s = 0;
            for(int j = 0; j < n;j++)
            {
                s+=p[j];
                h[i]-=s;
                if(h[i] <= 0)
                {
                    cout << j+1 << "\n";break;
                }
                if(j==n-1 && h[i] > 0) cout << -1 << "\n";
            }
        }
    }

}