#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
i64 X;
int K;
vector<i64> r;
int Q;
vector<i64> t;
vector<i64> a;
using P = pair<i64, i64>;
vector<P> query;
int main() {
  cin >> X >> K;
  r.resize(K);
  query.emplace_back(0, 0);
  for (int i = 0; i < K; i++) {
    cin >> r[i];
    query.emplace_back(r[i], -1);
  }
  cin >> Q;
  t.resize(Q);
  a.resize(Q);
  for (int(i) = (0); i <= (Q - 1); (i)++) {
    cin >> t[i] >> a[i];
    query.push_back({t[i], i});
  }
  sort(begin(query), end(query));
  int XX = X;
  int ZZ = 0;
  int cou = 0;
  int before = 0;
  i64 x = X;
  i64 z = 0;
  int sum = 0;
  vector<i64> ans(Q);
  for (int(i) = (0); i <= (query.size() - 1); (i)++) {
    P p = query[i];
    int index = p.second;
    int dif = p.first - before;
    if (cou % 2 == 0) {
      x -= dif;
      z -= dif;
      sum -= dif;
      if (x < 0) {
        x = 0;
      }
      if (z < 0) {
        ZZ += -z;
        z = 0;
      }
    } else {
      x += dif;
      z += dif;
      sum += dif;
      z = min(X, z);
      if (x > X) {
        XX -= x - X;
        x = X;
      }
    }
    if (p.second == -1) cou++;
    if (p.second > -1) {
      if (a[index] >= XX) {
        ans[index] = max(0LL, min(X, x));
        cout << 1 << " " << ans[index] << endl;
      } else if (a[index] <= ZZ) {
        ans[index] = max(0LL, min(X, z));
        cout << 2 << " " << ans[index] << endl;
      } else {
        ans[index] = sum + a[index];
        cout << 3 << " " << ans[index] << endl;
      }
    }
    before = p.first;
  }
  for (i64 an : ans) {
    cout << an << endl;
  }
}
