#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define run int teodorfonburgjenasgospodar; cin >> teodorfonburgjenasgospodar; while (teodorfonburgjenasgospodar--)
#define f first
#define s second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define cintienull ios_base::sync_with_stdio(0); cin.tie(0);
#define mp make_pair
#define inputV(a, n) for(int i = 0; i < n; i++)cin>>a[i];
#define ov(a, n) for(int i = 0; i < n; i++)cout << a[i] << " ";
#define ovr(a, n) for(int i = 0; i < n; i++)cout << a[i] << "\n";
#define INF 1000000000
#define LINF 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007;

//preko intervala
int main()
{
    cintienull
    int n,Q;
    cin >> n >> Q;
    vll d(n); vll p(n); vll q(n);
    for (int i = 0; i < n; i++) {
        cin >> d[i] >> p[i];
    }
    for (int i = 0; i < Q; i++) {
        cin >> q[i];
    }
    vpll desavanja;
    int p1=0,p2=0;
    while(p1 < n || p2 < Q){
        if((p1 != n && p2 != Q && d[p1] < q[p2])||p2 == Q){
            desavanja.pb(mp(d[p1], p[p1]));
            p1++;
        }
        else{
            desavanja.pb(mp(q[p2]+1, -1));
            p2++;
        }
    }
    ll dostupne = 0, pojedene = 0;
    if(desavanja[0].s == -1)cout << 0 <<'\n';
    else dostupne+=desavanja[0].s;
    int pok = 1;
    while (pok< desavanja.size()) {
        if(dostupne <= desavanja[pok].f- desavanja[pok-1].f){
            pojedene += dostupne;
            dostupne = 0;
        }
        else{
            pojedene += desavanja[pok].f - desavanja[pok-1].f;
            dostupne -= desavanja[pok].f - desavanja[pok-1].f;
        }
        if(desavanja[pok].s == -1){
            cout << pojedene << '\n';
        }
        else{
            dostupne += desavanja[pok].s;
        }
        pok++;
    }
}