#include <bits/stdc++.h>
using namespace std;
int X, N;
int r[100005];
int Q;
int work(int T, int a) {
  int t = 0;
  int f = 0;
  for (int i = 1; i <= N; i++) {
    if (r[i] > T) break;
    if (r[i] - t >= a) {
      a = 0;
    } else {
      a -= r[i] - t;
    }
    t = r[i];
    a = X - a;
    f ^= 1;
  }
  if (T - t >= a) {
    a = 0;
  } else {
    a -= T - t;
  }
  if (f == 0)
    return a;
  else
    return X - a;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> X >> N;
  for (int i = 1; i <= N; i++) {
    cin >> r[i];
    if (r[i] <= r[i - 1]) {
      cout << "ERROR" << endl;
      return 0;
    }
  }
  cin >> Q;
  while (Q--) {
    int t, a;
    cin >> t >> a;
    if (a > X) {
      cout << "XX" << endl;
      return 0;
    }
    cout << work(t, a) << endl;
  }
  return 0;
}
