#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
pair<long long, long long> a[MAXN];
long long ANS[MAXN];
int main() {
  long long m, n, i, j, k;
  scanf("%I64d %I64d", &m, &n);
  for (i = 1; i <= m; i++) scanf("%I64d", &a[i].first), a[i].second = i;
  sort(a + 1, a + 1 + m);
  long long ans = 9999999999999999, sz = 1;
  for (j = 1; j < m; j++) {
    long long maxn = a[m].first + a[j].first + n;
    long long minn = a[1].first + a[j + 1].first + n;
    if (j != 1) {
      minn = min(minn, a[1].first + a[2].first);
      maxn = max(maxn, a[j].first + a[j - 1].first);
    }
    if (j != m - 1) {
      maxn = max(maxn, a[m - 1].first + a[m].first);
      minn = min(minn, a[j + 1].first + a[j + 2].first);
    }
    if (maxn - minn < ans) {
      ans = maxn - minn;
      sz = j;
    }
  }
  if (a[m].first + a[m - 1].first - a[1].first - a[2].first < ans) {
    ans = a[m].first + a[m - 1].first - a[1].first - a[2].first;
    sz = 0;
  }
  for (i = 1; i <= sz; i++) ANS[a[i].second] = 1;
  for (i = sz + 1; i <= m; i++) ANS[a[i].second] = 2;
  cout << ans << endl;
  for (i = 1; i <= m; i++) cout << ANS[i] << ' ';
  cout << endl;
}
