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;
namespace SGT {
const int Maxn = 10000000;
int ch[Maxn][2], size[Maxn], tot;
inline int cpynode(int o) {
  tot++;
  ch[tot][0] = ch[o][0];
  ch[tot][1] = ch[o][1];
  size[tot] = size[o];
  return tot;
}
int build(int l, int r) {
  int o = ++tot;
  size[o] = r - l + 1;
  if (l == r)
    return o;
  else {
    int m = ((l + r) >> 1);
    ch[o][0] = build(l, m);
    ch[o][1] = build(m + 1, r);
    return o;
  }
}
int update(int l, int r, int o, int p) {
  o = cpynode(o);
  size[o]--;
  if (l == r)
    return 0;
  else {
    int m = ((l + r) >> 1);
    if (m >= p)
      ch[o][0] = update(l, m, ch[o][0], p);
    else
      ch[o][1] = update(m + 1, r, ch[o][1], p);
    return o;
  }
}
int query1(int l, int r, int o, int p) {
  if (!o) return 0;
  if (l == r)
    return size[o];
  else {
    int m = ((l + r) >> 1);
    if (m >= p)
      return query1(l, m, ch[o][0], p);
    else
      return query1(m + 1, r, ch[o][1], p) + size[ch[o][0]];
  }
}
int query2(int l, int r, int o, int k) {
  if (l == r)
    return l;
  else {
    int m = ((l + r) >> 1);
    if (size[ch[o][0]] >= k)
      return query2(l, m, ch[o][0], k);
    else
      return query2(m + 1, r, ch[o][1], k - size[ch[o][0]]);
  }
}
}  // namespace SGT
long long pos[100005], d[100005];
int len[100005], root[100005];
struct Query {
  int x, k, id;
  Query() {}
  Query(int a, int b, int c) : x(a), k(b), id(c) {}
  bool operator<(const Query& b) const { return x < b.x; }
};
Query q[100005];
long long ans[100005];
int num[100005];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%lld", &num[i]);
  int cnt = 0;
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x >= num[1])
      q[++cnt] = Query(x, y, i);
    else
      ans[i] = x;
  }
  sort(q + 1, q + cnt + 1);
  int r1 = n, r2 = cnt, sz = 0;
  pos[0] = 1e15;
  root[0] = SGT::build(1, n);
  while (r1) {
    long long t = (pos[sz] - num[r1] + r1 - 1) / r1, x = pos[sz] - t * r1;
    sz++;
    root[sz] = root[sz - 1];
    len[sz] = r1;
    pos[sz] = x;
    d[sz] = d[sz - 1] + t;
    while (r2 && q[r2].x >= x) {
      long long t = d[sz] - (q[r2].x - x) / r1;
      int u =
          SGT::query2(1, n, root[sz - 1], q[r2].x - (x + (d[sz] - t) * r1) + 1);
      int v = lower_bound(d + 1, d + sz + 1, t - q[r2].k) - d;
      long long nl = pos[v] + (d[v] - (t - q[r2].k)) * len[v];
      ans[q[r2].id] = nl + SGT::query1(1, n, root[v - 1], u) - 1;
      r2--;
    }
    while (r1 && num[r1] >= x) {
      int t = SGT::query2(1, n, root[sz - 1], num[r1] - x + 1);
      root[sz] = SGT::update(1, n, root[sz], t);
      r1--;
    }
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}