You are given a permutation P_1 ... P_N of the set {1, 2, ..., N}.

You can apply the following operation to this permutation, any number of times (possibly zero):

* Choose two indices i,j (1 ≦ i < j ≦ N), such that j - i ≧ K and |P_i - P_j| = 1. Then, swap the values of P_i and P_j.



Among all permutations that can be obtained by applying this operation to the given permutation, find the lexicographically smallest one.

Constraints

* 2≦N≦500,000
* 1≦K≦N-1
* P is a permutation of the set {1, 2, ..., N}.

Input

The input is given from Standard Input in the following format:


N K
P_1 P_2 ... P_N


Output

Print the lexicographically smallest permutation that can be obtained.

Examples

Input

4 2
4 2 3 1


Output

2
1
4
3


Input

5 1
5 4 3 2 1


Output

1
2
3
4
5


Input

8 3
4 5 7 8 3 1 2 6


Output

1
2
6
7
5
3
4
8
#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int c[4005][4005];
int a[4005];
const int mxs = 4005;
void read(int &a) {
  char ch = getchar();
  while (ch > '9' || ch < '0') ch = getchar();
  while (ch >= '0' && ch <= '9') a = a * 10 + ch - '0', ch = getchar();
}
int main() {
  for (int i = 0; i < 4005; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || j == i)
        c[i][j] = 1;
      else {
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 1000000007;
      }
    }
  }
  int test = 0;
  int n;
  if (test)
    n = 200000;
  else
    read(n);
  const int pls = 2001;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    int x, b;
    if (test)
      b = 1900 + rand() % 100, x = 1900 + rand() % 100;
    else
      read(x), read(b);
    x += b;
    double nans = 0;
    for (int j = pls - b; j <= min(mxs - 1, x + pls - b); j++) {
      long long q = 1ll * a[j] * c[x][b + j - pls];
      nans = (nans + q), ans = (ans + q);
    }
    ans -= (long long)(nans / 1000000007) * 1000000007;
    ans %= 1000000007;
    if (ans < 0) ans += 1000000007;
    for (int j = b + pls - x; j <= b + pls; j++) {
      a[j] += c[x][b + pls - j];
      a[j] = (a[j] >= 1000000007 ? a[j] - 1000000007 : a[j]);
    }
  }
  cout << ans << endl;
  return 0;
}
