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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,q;
    cin >> n >> q;
    int p[n],d[n];
    bool p0 = true,d0 = true;
    int pboljeodk[n];
    long long ds = 0;
    long long ps = 0;
    long long prefd[n];
    long long prefp[n];
    long long x = 0;
    for ( int i = 0 ; i < n ; i ++)
    {
        cin >> d[i] >> p[i];
        ds += d[i];
        if (i!= 0)ps += x;
        ps += p[i];
        x += p[i];
        prefd[i] = ds;
        prefp[i] = ps;
        if ( d[i] != 0) d0 = false;
        if ( p[i] != 0 ) p0 = false;
    }
    for ( int i = 0 ; i < n ; i++)
    {
        cout << prefp[i] << endl;
        int l = 1; int r = n;
        while(r-l > 1)
        {
            int mid = (r + l)/2;
            if ( d[i] > p[i]*mid) l = mid;
            else r = mid;
        }
        if ( p[i] == 0) pboljeodk[i] = 200001;
        else if (d[i] <= p[i]*l) pboljeodk[i] = l;
        else pboljeodk[i] = r;
    }
    while(q--)
    {
        int h; cin >> h;
        if ( p0)
        {
            if ( prefd[n-1] < h ) cout << -1 << endl;
            else
            {
                int l = 0;
                int r = n-1;
                while(r - l > 1)
                {
                    int mid = (r + l) /2;
                    if ( prefd[mid] >= h) r = mid;
                    else l = mid;
                }
                if ( prefd[l] >= h ) cout << l+1 << endl;
                else cout << r+1<< endl;
            }
        }
        else if(d0)
        {
            if ( prefp[n-1] < h ) cout << -1 << endl;
            else
            {
                int l = 0;
                int r = n-1;
                while(r - l > 1)
                {
                    int mid = (r + l) /2;
                    if ( prefp[mid] >= h) r = mid;
                    else l = mid;
                }
                if ( prefp[l] >= h ) cout << l+1 << endl;
                else cout << r+1<< endl;
            }
        }
        /*else
        {
            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 < dan ; i++)
                {
                    if ( pboljeodk[i] > dan - i) h2 -= d[i] ;
                    else h2 -= p[i]*(dan-i);
                }
                if ( h2 <= 0)
                {
                    r = dan;
                    moze = true;
                }
                else l = dan;
            }
            int h2 = h;
            for ( int i = 0 ; i < r ; i++)
            {
                if ( pboljeodk[i] > r - i) h2 -= d[i] ;
                else h2 -= p[i]*(r-i);
            }
            if ( h2 <= 0 && moze == false) cout << n << endl;
            else if (!moze) cout << -1 << endl;
            else if ( zadnji) cout << n << endl;
            else
            {
                for ( int i = 0 ; i < l ; i++)
                {
                    if ( pboljeodk[i] > l - i) h -= d[i];
                    else h -= p[i]*(l-i);
                }
                if ( h <= 0 )cout << l << endl;
                else cout << r << endl;
            }
        }
        */

    }
}