#include <iostream>
#include <cmath>
using namespace std;
struct plazmica{
    long int dan;
    long int kolko;
};

int main() {
    int N, Q;
    cin >> N >> Q;
    plazmica niz[N];
    unsigned int pitanja[Q];
    #include <iostream>
#include <cmath>
using namespace std;
struct plazmica{
    long int dan;
    long int kolko;
};

int main() {
    int N, Q;
    cin >> N >> Q;
    plazmica niz[N];
    unsigned int pitanja[Q];
    
    for(int i=0;i<N;++i)
        cin>>niz[i].dan>>niz[i].kolko;
    for(int i=0;i<Q;++i)
        cin>>pitanja[i];
    double koliko;
    
    for(int i=0;i<Q;++i){
        koliko=0;
        for(int j=0;j<pitanja[i] && j<N && pitanja[i]>niz[j].dan;++j){
            if((pitanja[i]-(niz[j].dan-1))>niz[j].kolko){
            koliko+=niz[j].kolko;
            }else{
            koliko+=(pitanja[i]-(niz[j].dan-1));
            }
        
        }
        cout<<koliko<<"\n";
    }
    
    return 0;
}

    for(int i=0;i<N;++i)
        cin>>niz[i].dan>>niz[i].kolko;
    for(int i=0;i<Q;++i)
        cin>>pitanja[i];
    double koliko;
    
    for(int i=0;i<Q;++i){
        koliko=0;
        for(int j=0;j<pitanja[i] && j<N && pitanja[i]>niz[j].dan;++j){
            if((pitanja[i]-(niz[j].dan-1))>niz[j].kolko){
            koliko+=niz[j].kolko;
            }else{
            koliko+=(pitanja[i]-(niz[j].dan-1));
            }
        
        }
        cout<<"\n"<<koliko;
    }
    
    return 0;
}