#include <bits/stdc++.h>
using namespace std;
template <class T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int ans[110];
int main() {
  int N, M;
  while (cin >> N >> M) {
    vector<pair<int, int> > X;
    vector<pair<int, int> > P;
    vector<int> A;
    int u, v;
    int color = 0;
    for (int i = (int)0, _m = (int)N; i < _m; ++i) {
      cin >> u;
      X.push_back(make_pair(u, i));
    }
    sort(X.begin(), X.end());
    for (int i = (int)0, _m = (int)(int)X.size(); i < _m; ++i) {
      ans[X[i].second] = color;
      color = 1 - color;
    }
    for (int j = (int)0, _m = (int)M; j < _m; ++j) {
      cin >> u >> v;
      P.push_back(make_pair(u, v));
    }
    bool ok = true;
    for (int j = (int)0, _m = (int)M; j < _m; ++j) {
      int red = 0;
      int black = 0;
      for (int i = (int)0, _m = (int)N; i < _m; ++i) {
        if (X[i].first >= P[j].first && X[i].first <= P[j].second) {
          if (ans[X[i].second])
            red++;
          else
            black++;
        }
      }
      if (Abs(red - black) > 1) {
        ok = false;
        break;
      }
    }
    ok = true;
    if (ok) {
      cout << ans[0];
      for (int i = (int)1, _m = (int)N; i < _m; ++i) cout << " " << ans[i];
      cout << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
