#include <iostream>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N,Q;
    cin >> N >> Q;
    
    vector<pair<int, ll> > v(N);
    for(int i = 0; i < N; ++i)
        cin >> v[i].first >> v[i].second;
        
    vector<ll> v_(Q);
    for(int i = 0; i < Q; ++i)
        cin >> v_[i];
        
    for(int i =0; i < Q; i++)
    {
        ll tDan = v_[i];
        ll stanje = 0;
        ll govno_pojelo = 0;
        
        for(int j = 0; j < N; ++j)
        {
            int danic = v[j].first;   
            ll pojea = v[j].second;
            
            if(danic > tDan) 
                break;
                
            
            stanje += pojea;
            
            ll sDan = tDan;
            if(j != N-1)
                sDan = min(sDan, (ll)v[j+1].first-1);
                
            ll bDana = sDan - danic + 1; // BROJACCCCCCCCCCCCCC
            
            ll plazmaShake = min(stanje, bDana);
            stanje -= plazmaShake;
            govno_pojelo += plazmaShake;
        }
        cout << govno_pojelo << endl;
        
    }
    return 0;
}