#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const long long inf = 0x3f3f3f3fll;
const long long mod = 998244353ll;
int n, m;
int ans[N];
int pos;
int loc[N];
struct node {
  int pre, nxt, val;
};
node a[N];
int main() {
  ios::sync_with_stdio(0);
  long long i, j;
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    cin >> a[i].val;
    loc[a[i].val] = i;
    a[i].pre = i - 1;
    a[i].nxt = (i + 1) % (n + 1);
  }
  pos = n;
  int _ = 1;
  while (pos) {
    int i1 = loc[pos];
    for (j = 1; j <= m; j++) {
      i1 = a[i1].pre;
      ans[i1] = _;
      loc[a[i1].val] = 0;
    }
    int i2 = loc[pos];
    for (j = 1; j <= m; j++) {
      i2 = a[i2].nxt;
      ans[i2] = _;
      loc[a[i2].val] = 0;
    }
    if (a[i1].pre) a[a[i1].pre].nxt = a[i2].nxt;
    if (a[i2].nxt) a[a[i2].nxt].pre = a[i1].pre;
    ans[loc[pos]] = _;
    loc[pos] = 0;
    _ = 3 - _;
    while (!loc[pos] && pos) pos--;
  }
  for (i = 1; i <= n; i++) cout << ans[i];
  return 0;
}
