#include <bits/stdc++.h>
using namespace std;
void parseArray(long long* A, long long n) {
  for (long long K = 0; K < n; K++) {
    cin >> A[K];
  }
}
long long modInverse(long long a, long long b) {
  return 1 < a ? b - modInverse(b % a, a) * b / a : 1;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long double dist(long long x, long long y, long long a, long long b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}
long long mod = 1000000007;
typedef struct node {
  node* next;
  node* prev;
  long long data;
} node;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  long long a[n];
  parseArray(a, n);
  set<long long> s;
  for (int k = 0; k < n; k++) {
    s.insert(k + 1);
  }
  node* L = NULL;
  node* map[n + 1];
  for (int k = 0; k < n; k++) {
    node* el = (node*)malloc(sizeof(node));
    map[a[k]] = el;
    el->next = NULL;
    el->prev = L;
    el->data = a[k];
    if (L) {
      L->next = el;
    }
    L = el;
  }
  long long ans[n + 1];
  long long pos;
  long long turn = 1;
  while (!s.empty()) {
    turn++;
    turn %= 2;
    set<long long>::iterator temp = s.end();
    temp--;
    pos = *temp;
    long long x = 0;
    node* p = map[pos];
    while (p->next && x < m) {
      x++;
      p = p->next;
      s.erase(p->data);
      ans[p->data] = turn + 1;
    }
    node* right = p->next;
    p = map[pos];
    x = 0;
    while (p->prev && x < m) {
      x++;
      p = p->prev;
      s.erase(p->data);
      ans[p->data] = turn + 1;
    }
    node* left = p->prev;
    ans[pos] = turn + 1;
    s.erase(pos);
    if (left) {
      left->next = right;
    }
    if (right) {
      right->prev = left;
    }
  }
  for (int k = 0; k < n; k++) {
    cout << ans[a[k]];
  }
  cout << endl;
  return 0;
}
