#include <bits/stdc++.h>
#define ll 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],p[n];
    int sum = 0;
    for(int i = 0; i < n;i++)
    {
        int t;
        cin >> t >> p[i];
        d[i] = t;
        sum+=t;
    }
    for(int i = 0; i < q;i++)
    {
        int h;
        cin >> h;
        int psum = 0;
        for(int j = 0;j < n;j++)
        {
            sum-= d[j];
            if(p[j]*(n-j)>sum || h-(psum+d[j]) > 0) psum+=p[j];
            else h-=d[j];
            h-=psum;
            if(h <= 0)
            {
                cout << j+1 << "\n";break;
            }
        }
        if(h > 0) cout << -1 << "\n";
    }
}