#include <bits/stdc++.h>
using namespace std;
struct node {
  int k, q, l, r;
};
node z[201000];
int t[201000];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> z[i].k;
    z[i].l = i - 1;
    z[i].r = i + 1;
    z[i].q = 0;
    t[z[i].k] = i;
  }
  int cnt = 2;
  for (int i = n; i >= 1; i--) {
    int p = t[i];
    if (!z[p].q) {
      cnt = 3 - cnt;
      z[p].q = cnt;
      int cnt1 = 0, cnt2 = 0, i, j;
      for (i = z[p].r; i <= n && cnt1 < m; i = z[i].r) {
        z[i].q = cnt;
        cnt1++;
      }
      for (j = z[p].l; j > 0 && cnt2 < m; j = z[j].l) {
        z[j].q = cnt;
        cnt2++;
      }
      z[j].r = i;
      z[i].l = j;
    }
  }
  for (int i = 1; i <= n; i++) cout << z[i].q;
}
