#include <algorithm> 
#include <iostream> 
#include <utility> 
#include <vector> 
using namespace std;  typedef long long ll;  int main() {   ll n, q, coonsuum = 0, rations = 0, position = 0;   cin >> n >> q;    vector<pair<ll, ll>> days(n + q);    for (ll i = 0; i < n; i++) {     cin >> days[i].first;     cin >> days[i].second;   }   for (ll i = n; i < q + n; i++) {     cin >> days[i].first;   }    sort(days.begin(), days.end());    for (auto day : days) {     if (day.first - position > rations) {       coonsuum += rations;       rations = 0;     } else {       coonsuum += day.first - position;       rations -= day.first - position;     }     position = day.first;      if (day.second == 0) {       cout << coonsuum + (rations ? 1 : 0) << endl;     }      rations += day.second;   }    return 0; }