#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,q,d,p,posdan=0,j=0,poj=0,zalihe=0,o=0;
    cin>>n>>q;
    vector<pair<long long int,long long int>> a;
    vector<long long int>c;
    long long int b[q];
    for(int i=0;i<n;i++){
        cin>>d>>p;
        a.push_back(make_pair(d,p));
    }
    for(int i=0;i<q;i++){
        cin>>b[i];
    }
    if(a[0].first>b[o]){
        cout<<"0"<<"\n";
        for(o=1;o<q;o++){
            if(a[0].first>b[o]){
                cout<<"0"<<"\n";
            }
            else{
                break;
            }
        }
    }
    if(a[0].first<=b[o]){
        posdan=a[0].first;
        for(int i=o;i<q;i++){
            while(posdan<=b[i] && j<n){
                zalihe=a[j].second+zalihe;
                a[j].second=0;
                if(b[i]-posdan+1>zalihe){
                    poj=poj+zalihe;
                    zalihe=0;
                    j++;
                    posdan=a[j].first;
                }
                else{
                    poj=poj+(b[i]-posdan+1);
                    zalihe=zalihe-(b[i]-posdan+1);
                    posdan=b[i];
                    break;
                }
            }
            cout<<poj<<"\n";
            
        }
    }
    return 0;
}