#pragma GCC optimize("Ofast,fast-math,unroll-loops")
  
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
  
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
  
using namespace std;
//using namespace __gnu_pbds;
         
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pll = pair <ll, ll>;
using pld = pair <ld, ld>;
 
/*
const ll MAX_MEM = 5e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
 
*/
 
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
         
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
         
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
         
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
         
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("circlecover.in", "r", stdin);
    //freopen("circlecover.out", "w", stdout);
}

struct node
{
    pii val;
    int vl, vr;
    node *l = 0, *r = 0;
    node() {}
    node(int tl, int tr, vector <int> &a)
    {
        vl = tl, vr = tr;
        if (vr - vl == 1)
        {
            val = {a[vl], vl};
            return;
        }
        l = new node(vl, (vl + vr) >> 1, a), r = new node((vl + vr) >> 1, vr, a);
        val = max(l->val, r->val);
    }
    void change(int pos, int x)
    {
        if (vr - vl == 1)
        {
            val = {x, pos};
            return;
        }
        int vm = (vl + vr) >> 1;
        if (pos < vm)
            l->change(pos, x);
        else
            r->change(pos, x);
        val = max(l->val, r->val);
    }
    pii get(int ql, int qr)
    {
        if (vl == ql && vr == qr)
            return val;
        int vm = (vl + vr) >> 1;
        if (qr <= vm)
            return l->get(ql, qr);
        if (ql >= vm)
            return r->get(ql, qr);
        return max(l->get(ql, vm), r->get(vm, qr));
    }
};

signed main()
{
    Start();
    int n, k;
    cin >> n >> k;
    vector <int> a(n);
    cin >> a;
    vector <vector <int>> b;
    for (int i = 0; i < n; ++i)
    {
        if (i % k == 0)
            b.pb(0);
        b.back().pb(a[i]);
    }
    int m = b.size();
    vector <node*> t;
    for (int i = 0; i < m; ++i)
        t.pb(new node(0, b[i].size(), b[i]));
    node *f = new node(0, n, a);
    set <pii> q;
    auto recalc = [&] (int i) -> void
    {
        auto g = t[i]->get(0, b[i].size());
        if (g.first == -1)
            return;
        if (g.first == f->get(max(0ll, g.second + i * k - k + 1), min(n, g.second + i * k + k)).first)
        {
            q.emplace(-(g.second + i * k), g.first);
        }
    };
    for (int i = 0; i < m; ++i)
        recalc(i);
    vector <int> ans(n);
    for (int i = n - 1; i >= 0; --i)
    {
        int pos = -q.begin()->first;
        q.erase(q.begin());
        int j = pos / k;
        t[j]->change(pos - j * k, -1);
        f->change(pos, -1);
        ans[pos] = i + 1;
        for (int l = j - 1; l <= j + 1; ++l)
            if (0 <= l && l < m)
                recalc(l);
    }
    for (auto &i : ans)
        cout << i << endl;
    return 0;
}



Measured memory_bytes: 167592