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>
int n, m, top, ttop;
long long a[100001];
long long ans[100001];
struct que {
  long long x, k, ord;
} num[100001], Que[100001];
long long lazy[1000001], se[1000001];
void pushdown(int root, long long y) { lazy[root] += y, se[root] += y; }
void spread(int root) {
  if (lazy[root]) {
    pushdown(root << 1, lazy[root]);
    pushdown(root << 1 | 1, lazy[root]);
    lazy[root] = 0;
  }
}
void pushup(int root) { se[root] = std::min(se[root << 1], se[root << 1 | 1]); }
void build(int root, int l, int r) {
  lazy[root] = 0;
  if (l == r) {
    se[root] = 1e15 + 1ll * l;
    return;
  }
  build(root << 1, l, (l + r) >> 1);
  build(root << 1 | 1, ((l + r) >> 1) + 1, r);
  pushup(root);
}
void update(int root, int l, int r, int el, int er, long long x) {
  if (el > r || er < l) return;
  if (el <= l && er >= r) {
    pushdown(root, x);
    return;
  }
  spread(root);
  update(root << 1, l, (l + r) >> 1, el, er, x);
  update(root << 1 | 1, ((l + r) >> 1) + 1, r, el, er, x);
  pushup(root);
}
int query(int root, int l, int r, long long x) {
  spread(root);
  if (l == r) return l;
  if (se[root << 1 | 1] <= x)
    return query(root << 1 | 1, ((l + r) >> 1) + 1, r, x);
  else
    return query(root << 1, l, (l + r) >> 1, x);
}
long long get(int root, int l, int r, int e) {
  spread(root);
  if (l == r) return se[root];
  if ((l + r) >> 1 >= e)
    return get(root << 1, l, (l + r) >> 1, e);
  else
    return get(root << 1 | 1, ((l + r) >> 1) + 1, r, e);
}
void clear(int &now) {
  while (se[1] <= a[now]) {
    int pos = query(1, 1, n, a[now]);
    update(1, 1, n, pos, pos, 1e16);
    update(1, 1, n, pos + 1, n, -1);
    --now;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", a + i);
  for (int i = 1; i <= m; i++) {
    ++top;
    scanf("%lld%lld", &num[top].x, &num[top].k);
    if (num[top].x < a[1])
      ans[i] = num[top--].x;
    else
      num[top].ord = i;
  }
  build(1, 1, n);
  std::sort(num + 1, num + top + 1, [&](que a, que b) { return a.x > b.x; });
  long long time = 0;
  for (int i = 1, now = n; i <= top; i++) {
    while (se[1] > num[i].x) {
      clear(now);
      if (a[now] > num[i].x) {
        time += (se[1] - a[now] + now - 1) / now;
        update(1, 1, n, 1, n, -1ll * ((se[1] - a[now] + now - 1) / now) * now);
      } else {
        time += (se[1] - num[i].x + now - 1) / now;
        update(1, 1, n, 1, n,
               -1ll * ((se[1] - num[i].x + now - 1) / now) * now);
      }
    }
    Que[++ttop] = (que){query(1, 1, n, num[i].x), time - num[i].k, num[i].ord};
  }
  build(1, 1, n);
  std::sort(Que + 1, Que + ttop + 1, [&](que a, que b) { return a.k < b.k; });
  time = 0;
  for (int i = 1, now = n; i <= ttop; i++) {
    while (time < Que[i].k) {
      clear(now);
      if (time + (se[1] - a[now] + now - 1) / now < Que[i].k) {
        time += (se[1] - a[now] + now - 1) / now;
        update(1, 1, n, 1, n, -1ll * ((se[1] - a[now] + now - 1) / now) * now);
      } else {
        update(1, 1, n, 1, n, -1ll * (Que[i].k - time) * now);
        time = Que[i].k;
      }
    }
    ans[Que[i].ord] = get(1, 1, n, Que[i].x);
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
}