#include <algorithm>
#include <bitset>
#include <iostream>
#include <vector>
#include <unordered_set>

typedef std::pair<int, int> Pair;
int MAX_SIZE_BITSET=300000;
std::vector<int> process(std::bitset<300000> dani,int n) {

std::vector<int> processq(300001, 0);
    processq[0]=dani[0];
    for (int i=0; i<300000; i++) {
        processq[i+1]=processq[i]+dani[i+1];
    }
    return processq;
}

std::vector<long long> PLAZMA  (std::vector<Pair> iD,std::vector<int> Q,int n) {
    int counter=0;
    std::bitset<300000> dani;
    dani.reset();
    std::vector<Pair> iDs = iD;
    std::sort(iDs.begin(), iDs.end());
    std::unordered_set<int> idsset;
    for (const auto& p : iDs) {
        idsset.insert(p.first - 1);
    }
    for(int i=0;i<dani.size();i++) {

        if (idsset.count(i)) {
            int k = 0;
            for (int j = 0; j < iDs.size(); j++) {
                if (iDs[j].first - 1 == i) {
                    k = j;
                    break;
                }
            }
            counter+=iDs[k].second;//jel k.first-1?
            counter--;
            dani[i]=true;
            //  continue;
        }else {
            if(counter<1) {
                continue;
            }
            counter--;
            dani[i]=true;
            //  continue;
        }
    }
    std::vector<int> w=process(dani,n);
    std::vector<long long> rez={};
    for(int i=0;i<Q.size();i++) {
        //izbrojim jedinice za svako q i to vratim u niz
        if(Q[i]>300000) {
            rez.push_back(3000000007);
        }
      else{ rez.push_back(w[Q[i]-1]);}
    }
    return rez;
}

int main()
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    int n,q;
    std::cin>>n>>q;
    std::vector<Pair> iD(n);
    for (int i=0;i<n;i++) {
        std::cin>>iD[i].first>>iD[i].second;
    }
    std::vector<int> Q(q);
    for (int i=0;i<q;i++) {
        std::cin>>Q[i];
    }
    std::vector<long long> plazma=PLAZMA(iD,Q,n);
    for(int i=0;i<plazma.size();i++) {
        std::cout<<plazma[i]<<'\n';
    }
    return 0;
}