Problem: There is a strip with an infinite number of cells. Cells are numbered starting with 0. Initially the cell i contains a ball with the number i.

There are n pockets located at cells a_1, …, a_n. Each cell contains at most one pocket.

Filtering is the following sequence of operations:

  * All pockets at cells a_1, …, a_n open simultaneously, which makes balls currently located at those cells disappear. After the balls disappear, the pockets close again.
  * For each cell i from 0 to ∞, if the cell i contains a ball, we move that ball to the free cell j with the lowest number. If there is no free cell j < i, the ball stays at the cell i.



Note that after each filtering operation each cell will still contain exactly one ball.

For example, let the cells 1, 3 and 4 contain pockets. The initial configuration of balls is shown below (underscores display the cells with pockets):

0 1 2 3 4 5 6 7 8 9 ... 

After opening and closing the pockets, balls 1, 3 and 4 disappear:

0  2  5 6 7 8 9 ... 

After moving all the balls to the left, the configuration looks like this:

0 2 5 6 7 8 9 10 11 12 ... 

Another filtering repetition results in the following:

0 5 8 9 10 11 12 13 14 15 ... 

You have to answer m questions. The i-th of these questions is "what is the number of the ball located at the cell x_i after k_i repetitions of the filtering operation?"

Input

The first line contains two integers n and m — the number of pockets and questions respectively (1 ≤ n, m ≤ 10^5).

The following line contains n integers a_1, …, a_n — the numbers of cells containing pockets (0 ≤ a_1 < … < a_n ≤ 10^9).

The following m lines describe questions. The i-th of these lines contains two integers x_i and k_i (0 ≤ x_i, k_i ≤ 10^9).

Output

Print m numbers — answers to the questions, in the same order as given in the input.

Example

Input

3 15
1 3 4
0 0
1 0
2 0
3 0
4 0
0 1
1 1
2 1
3 1
4 1
0 2
1 2
2 2
3 2
4 2


Output

0
1
2
3
4
0
2
5
6
7
0
5
8
9
10

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int K = 500;
int a[101010], b[101010], n, m;
struct data {
  int ost, oen, st, en, d;
  data(int ost = 0, int oen = 0, int st = 0, int en = 0, int d = 0)
      : ost(ost), oen(oen), st(st), en(en), d(d) {}
  bool operator<(const data &B) const { return ost < B.ost; }
};
data D[101010];
struct data_set {
  int ST, EN, e;
  int ost[K + 2], oen[K + 2], st[K + 2], en[K + 2], d[K + 2];
} S[101010 / K];
inline int nanugi(int a, int b) { return (a + b - 1) / b; }
void prep() {
  for (int i = K; i < n; i += K) {
    int st = b[i], en = b[i] + i - 2;
    int e = 0;
    D[++e] = data(st, en, st, en, 0);
    for (int j = i + 1, k, h, ost, oen, st, en, d; j <= min(i + K, n); j++) {
      int jj = j - 1;
      for (int f = 1; f <= e; f++) {
        k = nanugi(b[j] - D[f].st, jj);
        h = nanugi(b[j] - D[f].en, jj);
        if (k == h) {
          D[f].st += k * jj;
          D[f].en += k * jj;
          D[f].d += k;
        } else {
          ost = D[f].ost, oen = D[f].oen, st = D[f].st, en = D[f].en,
          d = D[f].d;
          int mid = b[j] - h * jj;
          D[++e] = data(ost, ost - st + mid - 1, st + k * jj, mid - 1 + k * jj,
                        d + k);
          D[f] = data(ost - st + mid, oen, mid + h * jj, en + h * jj, d + h);
        }
      }
    }
    sort(D + 1, D + e + 1);
    int id = i / K;
    S[id].e = e;
    S[id].ST = b[i];
    S[id].EN = b[i] + i - 2;
    for (int j = 1; j <= e; j++) {
      S[id].ost[j] = D[j].ost;
      S[id].oen[j] = D[j].oen;
      S[id].st[j] = D[j].st;
      S[id].en[j] = D[j].en;
      S[id].d[j] = D[j].d;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) b[i] = a[i] - i + 1;
  prep();
  int x, y;
  while (m--) {
    scanf("%d %d", &x, &y);
    if (x < b[1]) {
      printf("%d\n", x);
      continue;
    }
    int cur = lower_bound(b + 1, b + n + 1, x + 1) - b - 1;
    while (1) {
      if (!y || cur == n) {
        long long tmp = x + 1ll * y * n;
        printf("%I64d\n", tmp);
        break;
      }
      if (cur % K == 0) {
        int id = cur / K;
        if (S[id].EN >= x) {
          int i = lower_bound(S[id].oen + 1, S[id].oen + S[id].e + 1, x) -
                  S[id].oen;
          if (S[id].d[i] <= y) {
            y -= S[id].d[i];
            x += S[id].st[i] - S[id].ost[i];
            cur += K;
            cur = min(cur, n);
            continue;
          }
        }
      }
      int d = min(y, nanugi(b[cur + 1] - x, cur));
      y -= d, x += d * cur;
      cur++;
    }
  }
  return 0;
}