#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define PI acos(-1)
#define LSB(i) ((i) & -(i))
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define sc second
#define th third
#define fo fourth
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ldb double
#define INF 1e15
#define MOD 1000000007
#define endl "\n"

#define all(data)       data.begin(),data.end()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()
#define MAXN 300007
ll d[MAXN],p[MAXN],k[MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,q; cin>>n>>q;
    for(int i=1;i<=n;i++) cin>>d[i]>>p[i];
    for(int i=1;i<=q;i++) cin>>k[i];
    ll rez=0,rem=0,idx=0,lst=0; k[0]=0;
    for(int i=1;i<=q;i++)
    {
        ll x=min(rem,k[i]-lst);
        rez+=x; lst+=x; rem-=x;
        while(idx<n && d[idx+1]<=k[i])
        {
            idx++; rem+=p[idx];
            lst=max(lst,d[idx]-1);
            ll x=min(rem,k[i]-lst);
            rez+=x; lst+=x; rem-=x;
        }
        cout<<rez<<endl;
    }
    return 0;
}