Problem:
Score : 2000 points

Problem Statement

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.

Sample Input 1

4 2
4 2 3 1

Sample Output 1

2
1
4
3

One possible way to obtain the lexicographically smallest permutation is shown below:

4 2 3 1

4 1 3 2

3 1 4 2

2 1 4 3

Sample Input 2

5 1
5 4 3 2 1

Sample Output 2

1
2
3
4
5

Sample Input 3

8 3
4 5 7 8 3 1 2 6

Sample Output 3

1
2
6
7
5
3
4
8

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)

#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

const int INF=5e8;
struct segtree{
  int val[1100000];
  int n;
  void init(int n_){
    n=1;
    while(n<n_) n<<=1;
  }
  void set(int k,int a){
    k+=n-1;
    val[k]=a;
    while(k>0){
      k=(k-1)/2;
      val[k]=min(val[k*2+1],val[k*2+2]);
    }
  }
  int query(int a,int b,int i,int l,int r,int K){
    if(b<=l || r<+a || val[i]>=K) return INF;
    if(r-l==1) return l;
    int md=(l+r)>>1;
    int L=query(a,b,i*2+1,l,md,K);
    if(L==INF) return query(a,b,i*2+2,md,r,K);
    return L;
  }
  bool alive(int v){
    return val[v+n-1]<INF;
  }
};
segtree seg;

int n,K;
int ar[500005],br[500005];

int res[500005],cnt,ans[500005];
set<int> alive;
void rec(int v){
  seg.set(v,INF);
  while(1){
    int v2=seg.query(v+1,n,0,0,seg.n,ar[v]);
    if(v2>=v+K) break;
    rec(v2);
  }
  res[cnt++]=v;
}
int main(){
  cin>>n>>K;
  REP(i,n){
    scanf("%d",&ar[i]),--ar[i];
    br[ar[i]]=i;
  }
  seg.init(n);
  REP(i,n) seg.set(i,ar[i]);

  REP(i,n) if(seg.alive(i)){
    rec(i);
  }

  REP(i,n) ans[res[i]]=i;

  REP(i,n) printf("%d\n",ans[i]+1);

  return 0;
}