#include <bits/stdc++.h>
using namespace std;
long long x, n, q;
long long r[100010];
long long t, ans, down;
inline int read() {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  x = read();
  n = read();
  for (int i = 1; i <= n; i++) r[i] = read();
  q = read();
  while (q--) {
    t = read();
    ans = read();
    down = x - ans;
    int u = 0;
    int k = 1;
    int p = 1;
    bool flag = true;
    while (t--) {
      u++;
      if ((ans - k) >= 0 && (down + k) >= 0) {
        ans -= k;
        down += k;
      }
      if (u >= r[p] && flag == true) {
        k *= -1;
        p++;
      }
      if (p > n) flag = false;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
