#include <bits/stdc++.h>
using namespace std;
bool bool_poit[105];
bool colour_poit[105];
int abs(int a) { return a < 0 ? -a : a; }
int main() {
  int n, m;
  while (cin >> n >> m) {
    int a[105];
    memset(bool_poit, false, sizeof(bool_poit));
    memset(colour_poit, false, sizeof(colour_poit));
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      bool_poit[a[j]] = true;
    }
    bool before_colour = false;
    for (int j = 0; j < 105; j++) {
      if (bool_poit[j]) {
        before_colour = (before_colour ^ 1);
        colour_poit[j] = before_colour;
      }
    }
    bool ok = true;
    for (int j = 0; j < m; j++) {
      int red = 0, bule = 0;
      int left, right;
      cin >> left >> right;
      for (int k = left; k <= right; k++) {
        if (bool_poit[k]) {
          if (colour_poit[k])
            red++;
          else
            bule++;
        }
      }
      if (abs(red - bule) > 1) {
        ok = false;
      }
    }
    if (!ok) {
      cout << "-1" << endl;
      continue;
    }
    for (int j = 0; j < n; j++) {
      cout << colour_poit[a[j]] << " ";
    }
    cout << endl;
  }
}
