#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483640;
const int MAXN = 1000005;
int point[MAXN];
int l[MAXN], r[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (n); ++i) scanf("%d", &point[i]);
  for (int i = 0; i < (m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    l[i] = a;
    r[i] = b;
  }
  map<int, int> mp;
  for (int i = 0; i < (n); ++i) mp.insert(pair<int, int>(point[i], i));
  vector<int> ar(n);
  int tmp = 0;
  for (auto x : mp) {
    ar[x.second] = tmp;
    if (tmp == 0)
      tmp = 1;
    else
      tmp = 0;
  }
  vector<int> blue(m), red(m);
  for (int i = 0; i < (n); ++i)
    for (int j = 0; j < (m); ++j) {
      if (point[i] >= l[j] && point[i] <= r[j]) {
        if (ar[i] == 0)
          blue[j]++;
        else
          red[j]++;
      }
    }
  bool valid = true;
  for (int i = 0; i < (m); ++i)
    if (abs(red[i] - blue[i]) > 1) valid = false;
  if (valid)
    for (int i = 0; i < (n); ++i) printf("%d ", ar[i]);
  else
    printf("-1\n");
  return 0;
}
