#include <bits/stdc++.h>
using namespace std;
int n, m, b[1000000], t1, t0, l, r, x, a[1000000], z, num[10000000],
    q[10000000];
int main() {
  cin >> n >> m;
  for (int i = 0; i <= 1000; i++) b[i] = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    num[i] = i;
  }
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j < n; j++)
      if (a[i] > a[j]) {
        z = a[i];
        a[i] = a[j];
        a[j] = z;
        z = num[i];
        num[i] = num[j];
        num[j] = z;
      }
  }
  for (int i = 0; i < n; i++) {
    b[a[i]] = (i + 1) % 2;
    q[num[i]] = (i + 1) % 2;
  }
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    t1 = 0;
    t0 = 0;
    for (int j = l; j <= r; j++) {
      if (b[j] == 1) t1++;
      if (b[j] == 0) t0++;
    }
    if (abs(t1 - t0) > 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (int i = 0; i < n; i++) cout << q[i] << " ";
  cout << "\n";
}
