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;
using ll = long long;
const int MN = 1e5 + 1000;
const int MM = 1e5 + 1000;
using i3 = array<int, 3>;
using i2 = array<int, 2>;
using vi3 = vector<i3>;
int a[MN], N, M;
struct DT {
 public:
  vi3 v;
  int l;
  DT() { v.clear(); }
  DT operator+(const DT& o) const {
    const vi3& u = o.v;
    DT f;
    f.l = l;
    int i = 0, p = 0, d = a[o.l] - a[l], t;
    for (const i3& x : v) {
      i = o.get(p + x[1] - d)[0];
      for (; u[i][0] + d < x[0] + x[1]; i++)
        f.v.push_back({u[i][0] + d - x[1], u[i][1] + x[1], u[i][2] + x[2]});
      f.v.push_back({x[0], u[i][1] + x[1], u[i][2] + x[2]});
      p = x[0];
    }
    return f;
  }
  i3 get(int x) const {
    assert(0 <= x && x < l);
    int a = -1, b = v.size() - 1;
    for (; b - a > 1;) {
      int m = a + ((b - a) >> 1);
      if (x < v[m][0])
        b = m;
      else
        a = m;
    }
    return {b, v[b][1], v[b][2]};
  }
};
DT B[MN];
template <int MS = MN << 2>
struct ST {
  DT v[MS];
  void build(int n, int l, int r) {
    if (r - l > 1) {
      int m = l + ((r - l) >> 1);
      build(n << 1, l, m), build(n << 1 | 1, m, r);
      v[n] = v[n << 1] + v[n << 1 | 1];
    } else
      v[n] = B[l];
  }
  int S, E;
  void init(int a, int b) {
    S = a, E = b;
    build(1, a, b);
  }
  i3 qry(int n, int l, int r, i3 x) {
    assert(l <= x[0] && x[0] < r);
    if (l < x[0]) {
      assert(r - l > 1);
      int m = l + ((r - l) >> 1);
      if (x[0] < m) {
        i3 y = qry(n << 1, l, m, x);
        if (y[0] == m) y = qry(n << 1 | 1, m, r, y);
        return y;
      } else
        return qry(n << 1 | 1, m, r, x);
    } else {
      assert(x[0] == l);
      i3 q = v[n].get(x[1]);
      if (q[2] > x[2]) {
        if (r - l > 1) {
          int m = l + ((r - l) >> 1);
          i3 y = qry(n << 1, l, m, x);
          if (y[0] == m) y = qry(n << 1 | 1, m, r, y);
          return y;
        } else
          return x;
      } else
        return {r, x[1] + q[1] - (a[r] - a[l]), x[2] - q[2]};
    }
  }
  i3 qry(i3 x) { return qry(1, S, E, x); }
};
ST<> st;
int x, k;
int qry() {
  scanf("%d%d", &x, &k);
  if (x < a[1]) return printf("%d\n", x), 0;
  if (a[N] <= x) return printf("%lld\n", static_cast<ll>(k) * N + x), 0;
  int w = (upper_bound(a + 1, a + N + 1, x) - a) - 1;
  i3 f = st.qry({w, (x - a[w]) % w, k + (x - a[w]) / w});
  return printf("%lld\n", static_cast<ll>(f[2]) * f[0] + a[f[0]] + f[1]), 0;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) scanf("%d", a + i), a[i] -= i - 1;
  for (int i = 1; i < N; i++) {
    int d = a[i + 1] - a[i];
    B[i].l = i;
    if (d % i) {
      B[i].v.push_back({d % i, (d / i + 1) * i, d / i + 1});
      B[i].v.push_back({i, d / i * i, d / i});
    } else
      B[i].v.push_back({i, d, d / i});
  }
  st.init(1, N);
  while (M--) qry();
  return 0;
}