#include <iostream>
#include <vector>
#define ull unsigned long long
using namespace std;

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  vector<ull> v; // !?
  pair<ull, ull> in[n];
  for (int i=0; i<n; i++) {
    scanf("%llu %llu", &in[i].first, &in[i].second);
  }
  int iv=1, iin=0;
  int maxval=0;
  v.push_back(0);
  while (!(iin >= n && v[iv-1] >= maxval)) {
    if (iin < n && in[iin].first == iv) {
      if (v[iv-1] >= maxval) maxval = in[iin].second;
      else maxval += in[iin].second;
      iin++;
    }
    if (iv-1 < v.size() && v[iv-1] == maxval) v.push_back(v[iv-1]);
    else if (iv-1 < v.size()) v.push_back(v[iv-1]+1);
    iv++;
  }

  ull k;
  while (q--) {
    scanf("%llu", &k);
    printf("%llu\n", v[k]);
  }
}