#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<int> v;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<pair<long long, long long>> vpll;
typedef long double ld;
const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

void res() {
    int n, q;
    scanf("%d %d", &n, &q);
    vpll dp(n);
    vll tp(q);

    for (int i=0;i<n;++i) scanf("%lld %lld", &dp[i].fi,&dp[i].se);
    for (int i=0;i<q;++i) scanf("%lld", &tp[i]);
    for (int i=0;i<q;++i) {
        ll k=tp[i];
        ll res=0;
        ll ostk=0;
        int j=0;
        while (j<n && dp[j].fi<=k) {
            ll sld = (j+1<n) ? dp[j+1].fi : k+1;
            ll sldk = min(sld-dp[j].fi, k-dp[j].fi+1);
            ostk += dp[j].se;
            res += min(ostk,sldk);
            ostk -= min(ostk,sldk);
            j++;
        }
        printf("%lld\n", res);
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    res();
    return 0;
}