#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N, Q;
    cin >> N;
    cin >> Q;

    vector<int> d(N); 
    vector<int> k(N); 

    for (int i = 0; i < N; i++) {
        cin >> d[i];
        cin >> k[i];
    }

    vector<int> ppr(Q); 
    for (int i = 0; i < Q; i++) {
        cin >> ppr[i];
    }

    
    int r = 0;
    for (int i = 0; i < Q; i++) {
        int denjprekrachenija = ppr[i];  
        int vsegosjela = 0;
        

        
        for (r = 0; r < N && k[r] < denjprekrachenija; r++) {
            vsegosjela = vsegosjela +k[r];
        }
            
           

        
        cout << vsegosjela << endl;
    }

    return 0;
}