#include <bits/stdc++.h>   using namespace std;   int e, s, n, m;   vector<int> comp;   vector<pair<int, int> > has;   vector<int> all, butR, onlyS;   int query[200013];   int id(int x) {     return lower_bound(comp.begin(), comp.end(), x) - comp.begin();   }   vector<int> cover(int use) {     vector<int> res(comp.size());     for (auto i : has)       if (i.second >= use) {         res[id(i.first)] += 1;         res[id(i.first + s)] -= 1;       }     int prev = 0;     for (int& i : res) i += prev, prev = i;     for (int i = 0; i < res.size() - 1; i++) {       if (res[i]) res[i] = comp[i + 1] - comp[i];     }     prev = 0;     for (int& i : res) i += prev, prev = i;     return res;   }   bool test(vector<int>& vec, int ind) {     return ind != 0 && vec[ind] > vec[ind - 1];   }   pair<int, int> solve(int f) {     if (f + s >= e) return make_pair(0, 0);     f += s;     int eAt = id(e) - 1, fAt = id(f) - 1;     if (all[eAt] - all[fAt] != e - f) return make_pair(-1, -1);     int needR = (e - f) - (butR[eAt] - butR[fAt]);     int needP = (e - f) - (onlyS[eAt] - onlyS[fAt]) - needR;     return make_pair(needR, needP);   }   int main() {     scanf( %d%d%d%d , &e, &s, &n, &m);     comp.push_back(e);     comp.push_back(-1.01e9);     for (int i = 0; i < n; i++) {       int t, x;       scanf( %d%d , &t, &x);       if (x >= e) continue;       has.push_back(make_pair(x, t));       comp.push_back(x);       comp.push_back(x + s);     }     for (int i = 0; i < m; i++) {       scanf( %d , &query[i]);       comp.push_back(query[i]);       comp.push_back(query[i] + s);     }     sort(comp.begin(), comp.end());     comp.erase(unique(comp.begin(), comp.end()), comp.end());     all = cover(1);     butR = cover(2);     onlyS = cover(3);     for (int i = 0; i < m; i++) {       pair<int, int> ans = solve(query[i]);       printf( %d %d n , ans.first, ans.second);     }     return 0;   }   