#include<iostream>
#include<vector> 
using namespace std;
int main(){
    int N,Q;
    cin>>N>>Q;
    vector <long long>dani(N);
    vector<long long>prefixSum(N);
    for(int i=0;i<N;i++){
        long long d,p;
        cin>>d>>p;
        if(i==0){
            prefixSum[i]=p;
        }else{
            prefixSum[i]=prefixSum[i-1]+p;
        }
    }
    for(int j=0;j<Q;j++){
        long long kj;
        cin>>kj;int low=0, high=N-1;
        int result=-1;
        while(low<=high){
            int mid=(low+high)/2;
            if(dani[mid]<=kj){
                result=mid;
                low=mid+1;
            }else{
                high=mid-1;
            }
        }if ?(result!=-1){
            cout<<prefixSum[result];
        }else{
            cout<<0;
        }
    }
    return 0;
}