#include <bits/stdc++.h>
using namespace std;
const int K = 500;
int a[101010], b[101010], n, m;
struct data {
  int st, en, mov, d;
  data(int st = 0, int en = 0, int mov = 0, int d = 0)
      : st(st), en(en), mov(mov), d(d) {}
  bool operator<(const data &B) const { return st < B.st; }
};
data D[K + 2];
int x, y;
struct data_set {
  int e, dmn;
  vector<int> en, mov, d;
  void init(int sz) {
    e = sz;
    en.resize(e + 1);
    mov.resize(e + 1);
    d.resize(e + 1);
  }
  bool check() {
    if (en[e] < x || dmn > y) return 0;
    int i = lower_bound(en.begin() + 1, en.begin() + e + 1, x) - en.begin();
    if (d[i] > y) return 0;
    y -= d[i];
    x += mov[i];
    return 1;
  }
  void refresh() {
    dmn = d[1];
    for (int i = 2; i <= e; i++) dmn = min(dmn, d[i]);
  }
} 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, 0, 0);
    for (int j = i + 1, k, h; j <= min(i + K, n); j++) {
      int jj = j - 1;
      for (int f = 1; f <= e; f++) {
        k = nanugi(b[j] - D[f].st - D[f].mov, jj);
        h = nanugi(b[j] - D[f].en - D[f].mov, jj);
        if (k == h) {
          D[f].mov += k * jj;
          D[f].d += k;
        } else {
          int mid = b[j] - h * jj;
          D[++e] =
              data(D[f].st, -D[f].mov + mid - 1, D[f].mov + k * jj, D[f].d + k);
          D[f] = data(-D[f].mov + mid, D[f].en, D[f].mov + h * jj, D[f].d + h);
        }
      }
    }
    sort(D + 1, D + e + 1);
    int id = i / K;
    S[id].init(e);
    for (int j = 1; j <= e; j++) {
      S[id].en[j] = D[j].en;
      S[id].mov[j] = D[j].mov;
      S[id].d[j] = D[j].d;
    }
    S[id].refresh();
  }
}
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();
  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;
    int d;
    while (1) {
      if (!y || cur == n) {
        long long tmp = x + 1ll * y * n;
        printf("%I64d\n", tmp);
        break;
      }
      if (cur % K == 0) {
        if (S[cur / K].check()) {
          cur = min(cur + K, n);
          continue;
        }
      }
      d = min(y, nanugi(b[cur + 1] - x, cur));
      y -= d, x += d * cur;
      cur++;
    }
  }
  return 0;
}

### Prompt

Create a solution in CPP for the following 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int K = 500;
int a[101010], b[101010], n, m;
struct data {
  int st, en, mov, d;
  data(int st = 0, int en = 0, int mov = 0, int d = 0)
      : st(st), en(en), mov(mov), d(d) {}
  bool operator<(const data &B) const { return st < B.st; }
};
data D[K + 2];
int x, y;
struct data_set {
  int e, dmn;
  vector<int> en, mov, d;
  void init(int sz) {
    e = sz;
    en.resize(e + 1);
    mov.resize(e + 1);
    d.resize(e + 1);
  }
  bool check() {
    if (en[e] < x || dmn > y) return 0;
    int i = lower_bound(en.begin() + 1, en.begin() + e + 1, x) - en.begin();
    if (d[i] > y) return 0;
    y -= d[i];
    x += mov[i];
    return 1;
  }
  void refresh() {
    dmn = d[1];
    for (int i = 2; i <= e; i++) dmn = min(dmn, d[i]);
  }
} 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, 0, 0);
    for (int j = i + 1, k, h; j <= min(i + K, n); j++) {
      int jj = j - 1;
      for (int f = 1; f <= e; f++) {
        k = nanugi(b[j] - D[f].st - D[f].mov, jj);
        h = nanugi(b[j] - D[f].en - D[f].mov, jj);
        if (k == h) {
          D[f].mov += k * jj;
          D[f].d += k;
        } else {
          int mid = b[j] - h * jj;
          D[++e] =
              data(D[f].st, -D[f].mov + mid - 1, D[f].mov + k * jj, D[f].d + k);
          D[f] = data(-D[f].mov + mid, D[f].en, D[f].mov + h * jj, D[f].d + h);
        }
      }
    }
    sort(D + 1, D + e + 1);
    int id = i / K;
    S[id].init(e);
    for (int j = 1; j <= e; j++) {
      S[id].en[j] = D[j].en;
      S[id].mov[j] = D[j].mov;
      S[id].d[j] = D[j].d;
    }
    S[id].refresh();
  }
}
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();
  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;
    int d;
    while (1) {
      if (!y || cur == n) {
        long long tmp = x + 1ll * y * n;
        printf("%I64d\n", tmp);
        break;
      }
      if (cur % K == 0) {
        if (S[cur / K].check()) {
          cur = min(cur + K, n);
          continue;
        }
      }
      d = min(y, nanugi(b[cur + 1] - x, cur));
      y -= d, x += d * cur;
      cur++;
    }
  }
  return 0;
}

```