#include <iostream>
#include <bits/stdc++.h>
#include <string>
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

ll prviveci(ll pocetak[], ll n, ll dan)
{
    ll L = 0, D = n - 1, S = 0, resenje = -1;
    while(L <= D)
    {
        S = (L + D) / 2;
        if(pocetak[S] <= dan)
        {
            L = S + 1;
        }
        else
        {
            resenje = S;
            D = S - 1;
        }

    }
    return resenje;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cerr.tie(0);


    ll N, Q, d, p, i, tr = 0, j, ukupno = 0;
    cin >> N >> Q;
    ll pocetak[N];
    ll duzina[N];
    ll doTada[N];

    cin >> d >> p;

    pocetak[0] = d;
    duzina[0] = p;
    doTada[0] = 0;

    ukupno += p;

    for(i=1; i<N; i++)
    {
        cin >> d >> p;
        if(d <= pocetak[tr] + duzina[tr])
        {
            duzina[tr] += p;
        }
        else
        {
            tr++;
            pocetak[tr] = d;
            duzina[tr] = p;
            doTada[tr] = ukupno;
        }
        ukupno += p;
    }

    /*for(i=0; i<=tr; i++)
    {
        cout << get<0>(plazma[i]) << " " << get<1>(plazma[i]) << " " << get<2>(plazma[i]) << endl;
    }*/

    for(i=0; i<Q; i++)
    {
        cin >> d;
        ll index_grupe = prviveci(pocetak, tr+1, d);
        if(index_grupe == 0)
        {
            cout << 0 << endl;
        }
        else
        {
            if(index_grupe == -1)
            {
                index_grupe = tr;
            }
            else
            {
                index_grupe--;
            }
            ll resenje = doTada[index_grupe] + min(duzina[index_grupe], (d + 1 - pocetak[index_grupe]));
            cout << resenje << endl;
        }
    }


}