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;
int n;
int m;
int a[100005];
pair<int, int> q[100005];
vector<int> group[100005];
long long ans[100005];
struct Node {
  int id;
  int num;
  int cnt;
  int minCnt;
  int lazyNum;
  int lazyCnt;
  int priority;
  Node* leftChild;
  Node* rightChild;
  Node(int id, int num, int cnt) {
    this->id = id;
    this->num = num;
    this->cnt = cnt;
    minCnt = cnt;
    lazyCnt = lazyNum = 0;
    leftChild = rightChild = 0;
    priority = rand();
  }
};
inline void update(Node* p) {
  p->minCnt = p->cnt;
  if (p->leftChild) {
    p->minCnt = min(p->minCnt, p->leftChild->minCnt);
  }
  if (p->rightChild) {
    p->minCnt = min(p->minCnt, p->rightChild->minCnt);
  }
}
inline void applyNum(Node* p, int f) {
  if (p) {
    p->num += f;
    p->lazyNum += f;
  }
}
inline void applyCnt(Node* p, int f) {
  if (p) {
    p->cnt -= f;
    p->minCnt -= f;
    p->lazyCnt += f;
  }
}
void lazyPropagation(Node* p) {
  if (p->lazyNum) {
    applyNum(p->leftChild, p->lazyNum);
    applyNum(p->rightChild, p->lazyNum);
    p->lazyNum = 0;
  }
  if (p->lazyCnt) {
    applyCnt(p->leftChild, p->lazyCnt);
    applyCnt(p->rightChild, p->lazyCnt);
    p->lazyCnt = 0;
  }
}
Node* merge(Node* l, Node* r) {
  if (!l || !r) {
    return l ? l : r;
  }
  if (l->priority > r->priority) {
    lazyPropagation(l);
    l->minCnt = min(l->minCnt, r->minCnt);
    l->rightChild = merge(l->rightChild, r);
    return l;
  } else {
    lazyPropagation(r);
    r->minCnt = min(l->minCnt, r->minCnt);
    r->leftChild = merge(l, r->leftChild);
    return r;
  }
}
void split(Node* p, int x, Node*& l, Node*& r) {
  if (!p) {
    l = r = 0;
  } else {
    lazyPropagation(p);
    if (p->num > x) {
      r = p;
      split(p->leftChild, x, l, p->leftChild);
    } else {
      l = p;
      split(p->rightChild, x, p->rightChild, r);
    }
    update(p);
  }
}
void insert(Node*& f, Node* p) {
  if (!f) {
    f = p;
  } else {
    lazyPropagation(f);
    if (f->priority < p->priority) {
      split(f, p->num, p->leftChild, p->rightChild);
      f = p;
    } else {
      insert(f->num > p->num ? f->leftChild : f->rightChild, p);
    }
    update(f);
  }
}
Node* remove(Node* f, Node*& p, int d) {
  lazyPropagation(f);
  if (f->cnt <= d) {
    p = f;
    return merge(f->leftChild, f->rightChild);
  } else {
    if (f->leftChild && f->leftChild->minCnt == f->minCnt) {
      f->leftChild = remove(f->leftChild, p, d);
    } else {
      f->rightChild = remove(f->rightChild, p, d);
    }
    update(f);
    return f;
  }
}
void solve(Node*& f, int d, int i) {
  while (f && (i == n || f->minCnt <= d)) {
    Node* p;
    f = remove(f, p, d);
    ans[p->id] = 1LL * p->cnt * i + a[i] - (i - p->num - 1);
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &q[i].first, &q[i].second);
    int j = upper_bound(a + 1, a + n + 1, q[i].first) - a - 1;
    group[j].push_back(i);
  }
  Node* root = 0;
  for (int i = 0; i <= n; i++) {
    if (i > 0 && i < n) {
      int p = (a[i + 1] - a[i] - 1) / i;
      int x = (a[i] + p * i) - (a[i + 1] - i);
      Node* l;
      Node* r;
      split(root, i - x - 2, l, r);
      solve(l, p + 1, i);
      solve(r, p, i);
      if (l) {
        applyNum(l, x + 1);
        applyCnt(l, p + 1);
      }
      if (r) {
        applyNum(r, x - i + 1);
        applyCnt(r, p);
      }
      root = merge(r, l);
    }
    for (int id : group[i]) {
      long long x = q[id].first;
      long long k = q[id].second;
      if (i == n || x + k * i < a[i + 1]) {
        ans[id] = x + k * i;
      } else {
        int p = (a[i + 1] - x - 1) / i;
        Node* f = new Node(id, i - a[i + 1] + x + p * i, k - p);
        insert(root, f);
      }
    }
  }
  solve(root, 1e9, n);
  for (int i = 0; i < m; i++) {
    printf("%lld\n", ans[i]);
  }
}