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 + 10;
const long long X = 1e15;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while (!isdigit(ch) && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
struct dat {
  long long t;
  int y, id;
  bool operator<(const dat &A) const { return t < A.t; }
};
int n, m, a[N], k[N], ls[N], rs[N], key[N], rt, siz[N];
long long ans[N];
vector<pair<int, int> > vec1;
vector<dat> vec2;
mt19937 rng(20020415);
void up(int x) { siz[x] = siz[ls[x]] + siz[rs[x]] + 1; }
int merge(int x, int y) {
  if (!x || !y) return x | y;
  if (key[x] < key[y]) {
    rs[x] = merge(rs[x], y);
    up(x);
    return x;
  } else {
    ls[y] = merge(x, ls[y]);
    up(y);
    return y;
  }
}
void split(int x, int k, int &a, int &b) {
  if (!x) {
    a = b = 0;
    return;
  }
  if (siz[ls[x]] < k) {
    a = x;
    split(rs[x], k - siz[ls[x]] - 1, rs[a], b);
  } else {
    b = x;
    split(ls[x], k, a, ls[b]);
  }
  up(x);
}
int findkth(int k) {
  int a, b, c;
  split(rt, k - 1, a, b);
  split(b, 1, b, c);
  int ret = b;
  rt = merge(a, merge(b, c));
  return ret;
}
void erasekth(int k) {
  int a, b, c;
  split(rt, k - 1, a, b);
  split(b, 1, b, c);
  rt = merge(a, c);
}
int getrank(int x, int id) {
  if (!x) return 0;
  if (x <= id) return siz[ls[x]] + 1 + getrank(rs[x], id);
  return getrank(ls[x], id);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) a[i] = gi(), vec1.push_back(make_pair(a[i], 0));
  for (int i = 1; i <= m; i++) {
    int x = gi();
    k[i] = gi();
    if (x < a[1])
      ans[i] = x;
    else
      vec1.push_back(make_pair(x, i));
  }
  sort(vec1.begin(), vec1.end(), greater<pair<int, int> >());
  long long s = X + 1, tim = 0;
  for (int i = 1; i <= n; i++) {
    siz[i] = 1;
    key[i] = rng();
    rt = merge(rt, i);
  }
  for (auto t : vec1) {
    long long tar = t.first;
    int id = t.second;
    if (s > tar) {
      int l = lower_bound(a + 1, a + n + 1, s) - a;
      int r = upper_bound(a + 1, a + n + 1, s + siz[rt] - 1) - a - 1;
      for (int i = r; i >= l; i--) erasekth(a[i] - s + 1);
      long long tmp = (s - tar - 1) / siz[rt] + 1;
      s -= tmp * siz[rt];
      tim += tmp;
    }
    vec2.push_back((dat){tim, 0, 0});
    if (id) {
      vec2.push_back((dat){tim - k[id], findkth(tar - s + 1), id});
    }
  }
  sort(vec2.begin(), vec2.end());
  s = X + 1;
  tim = 0;
  rt = 0;
  for (int i = 1; i <= n; i++) {
    siz[i] = 1, ls[i] = rs[i] = 0;
    rt = merge(rt, i);
  }
  for (auto t : vec2) {
    long long tar = t.t;
    int y = t.y, id = t.id;
    if (tar > tim) {
      int l = lower_bound(a + 1, a + n + 1, s) - a;
      int r = upper_bound(a + 1, a + n + 1, s + siz[rt] - 1) - a - 1;
      for (int i = r; i >= l; i--) erasekth(a[i] - s + 1);
    }
    s -= (tar - tim) * siz[rt];
    tim = tar;
    if (id) {
      ans[id] = s + getrank(rt, y) - 1;
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << '\n';
  return 0;
}