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 N = 1e5 + 7;
int n, m, a[N], ddd;
struct Data {
  int x, y, u, k;
  Data(int _x = 0, int _y = 0, int _u = 0, int _k = 0) {
    x = _x;
    y = _y;
    u = _u;
    k = _k;
  }
  bool operator<(const Data &oth) const { return x < oth.x; }
};
struct SegmentTree {
  vector<Data> d[N * 4];
  void build(int id, int l, int r) {
    if (l == r) {
      int mid = (a[l + 1] - a[l]) % l;
      int k = (a[l + 1] - a[l] + l - 1) / l;
      int u = a[l] + l * k - a[l + 1];
      if (mid == 0) {
        d[id].push_back(Data(0, l - 1, u, k));
      } else {
        d[id].push_back(Data(0, mid - 1, u, k));
        d[id].push_back(Data(mid, l - 1, 0, k - 1));
      }
      return;
    }
    int mid = (l + r) >> 1;
    build(id << 1, l, mid);
    build(id << 1 | 1, mid + 1, r);
    int cur = 0;
    for (Data dat : d[id << 1])
      while (cur <= dat.y) {
        int x = cur;
        int nX = dat.u + (x - dat.x);
        Data nxt = *(--upper_bound(d[id << 1 | 1].begin(), d[id << 1 | 1].end(),
                                   Data(nX)));
        int u = nxt.u + (nX - nxt.x);
        int y = x + min(dat.y - x, nxt.y - nX);
        int k = dat.k + nxt.k;
        d[id].push_back(Data(x, y, u, k));
        cur = y + 1;
      }
  }
  void go(int id, int l, int r, int &x, int &k) {
    ++ddd;
    if (x < a[l] || a[r + 1] <= x) return;
    if (a[l] <= x && x < a[l] + l) {
      int curX = x - a[l];
      assert(curX < l);
      Data dat = *(--upper_bound(d[id].begin(), d[id].end(), Data(curX)));
      if (k >= dat.k) {
        k -= dat.k;
        x = a[r + 1] + dat.u + (curX - dat.x);
        return;
      }
    }
    if (l == r) return;
    int mid = (l + r) >> 1;
    go(id << 1, l, mid, x, k);
    go(id << 1 | 1, mid + 1, r, x, k);
  }
} ST;
int brute(int x, int k) {
  int p = 0;
  while (k--) {
    while (p < n && a[p + 1] <= x) p++;
    x += p;
  }
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] -= i - 1;
  }
  if (n > 1) ST.build(1, 1, n - 1);
  while (m--) {
    int x, k;
    cin >> x >> k;
    if (x < a[1]) {
      cout << x << '\n';
      continue;
    }
    if (a[n] <= x) {
      cout << x + (long long)n * k << '\n';
      continue;
    }
    int p = upper_bound(a + 1, a + 1 + n, x) - a - 1;
    int c = min(k, (a[p + 1] - x + p - 1) / p);
    x += c * p;
    k -= c;
    if (k == 0) {
      cout << x << '\n';
      continue;
    }
    ST.go(1, 1, n - 1, x, k);
    p = upper_bound(a + 1, a + 1 + n, x) - a - 1;
    cout << x + (long long)k * p << '\n';
  }
  return 0;
}