#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n,q;
    cin >> n >> q;
    int p[n],d[n];
    int pboljeodk[n];
    for ( int i = 0 ; i < n ; i ++) cin >> d[i] >> p[i];
    for ( int i = 0 ; i < n ; i++)
    {
        int l = 1; int r = n;
        while(r-l > 1)
        {
            int mid = (r + l)/2;
            if ( d[i] * mid > p[i]*mid*(mid+1)/2) l = mid;
            else r = mid;
        }
        if ( p[i] == 0) pboljeodk[i] = -1;
        else if (d[i] * l <= p[i]*l*(l+1)/2) pboljeodk[i] = l;
        else pboljeodk[i] = r;
    }
    while(q--)
    {
        int h; cin >> h;
        int l = 1;
        int r = n;
        bool moze = false;
        bool zadnji = false;
        while(r-l > 1)
        {
            int h2 = h;
            int dan = ( l + r ) / 2;
            for ( int i = 0 ; i < n ; i++)
            {
                if ( pboljeodk[i] <= dan - i) h2 -= d[i] * (dan-i);
                else h2 -= p[i]*(dan-i)*(dan-i+1)/2;
            }
            if ( h2 <= 0)
            {
                r = dan;
                moze = true;
            }
            else l = dan;
        }
        int h2 = h;
        for ( int i = 0 ; i < n ; i++)
        {
            if ( pboljeodk[i] <= r - i) h2 -= d[i] * (r-i);
            else h2 -= p[i]*(r-i)*(r-i+1)/2;
        }
        if ( h2 <= 0 && moze == false)
        {
            moze = true;
            zadnji = true;
        }
        if (!moze) cout << -1 << endl;
        else if ( zadnji) cout << n << endl;
        else
        {
            for ( int i = 0 ; i < n ; i++)
            {
                if ( pboljeodk[i] <= l - i) h -= d[i] * (l-i);
                else h -= p[i]*(l-i)*(l-i+1)/2;
            }
            if ( h <= 0 )cout << l-1 << endl;
            else cout << r-1 << endl;
        }
    }
}