#include <bits/stdc++.h>

using namespace std;

struct ez{
  long long day;
  int qty;
};

bool cmp(const ez& e1, const ez& e2){
  if(e1.day < e2.day) return true;
  if(e1.day > e2.day) return false;
  if(e1.qty > e2.qty) return true;
  return false;
}

int main(){

  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int m, k;

  cin >> m >> k;

  int n = m + k;
  vector<ez> a(n);

  for(int i = 0; i < m; ++i) cin >> a[i].day >> a[i].qty;
  for(int i = m; i < n; ++i) { cin >> a[i].day; a[i].qty = -1; }

  sort(a.begin(), a.end(), cmp);

  long long ans = 0, buf = 0;
  for(int i = 0; i < n; ++i){
    if(a[i].qty != -1) buf += (long long) a[i].qty;
    if(buf) ++ans, --buf;

    if(a[i].qty == -1) cout << ans << '\n';
    if(i+1 == n) break;

    long long dif = min(buf, a[i+1].day-a[i].day-1);
    ans += dif, buf -= dif;
  }

  return 0;
}