#include <iostream>
#include <cstdint>
#include <algorithm>

uint64_t odgovor(uint64_t *D, uint64_t *P, uint64_t k, uint64_t n){
  uint64_t s = 0;
  int i = 0;
  while(D[i] <= k && i < n){
    s += std::min(P[i], k-D[i]+1);
    if(s > k) return k;
    i++;
  }
  return s;
}

int main(){
  uint64_t *D = new uint64_t[300000];
  uint64_t *P = new uint64_t[300000];
  uint64_t n, nq, q, d, p;

  std::cin >> n >> nq;
  for(int i = 0; i < n; i++){
    std:: cin >> d >> p;
    D[i] = d;
    P[i] = p;
  }
  uint64_t *O = new uint64_t[300000];
  for(int i = 0; i < nq; i++){
    std::cin >> q;
    O[i] = odgovor(D, P, q, n);
  }
  for(int i = 0; i < nq; i++){
    std::cout << O[i] << "\n";
  }
}