Problem: Iahub isn't well prepared on geometry problems, but he heard that this year there will be a lot of geometry problems on the IOI selection camp. Scared, Iahub locked himself in the basement and started thinking of new problems of this kind. One of them is the following.

Iahub wants to draw n distinct segments [li, ri] on the OX axis. He can draw each segment with either red or blue. The drawing is good if and only if the following requirement is met: for each point x of the OX axis consider all the segments that contains point x; suppose, that rx red segments and bx blue segments contain point x; for each point x inequality |rx - bx| ≤ 1 must be satisfied.

A segment [l, r] contains a point x if and only if l ≤ x ≤ r.

Iahub gives you the starting and ending points of all the segments. You have to find any good drawing for him.

Input

The first line of input contains integer n (1 ≤ n ≤ 105) — the number of segments. The i-th of the next n lines contains two integers li and ri (0 ≤ li ≤ ri ≤ 109) — the borders of the i-th segment.

It's guaranteed that all the segments are distinct.

Output

If there is no good drawing for a given test, output a single integer -1. Otherwise output n integers; each integer must be 0 or 1. The i-th number denotes the color of the i-th segment (0 is red and 1 is blue).

If there are multiple good drawings you can output any of them.

Examples

Input

2
0 2
2 3


Output

0 1


Input

6
1 5
1 3
3 5
2 10
11 11
12 12


Output

0 1 0 1 0 0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
namespace io {
const int SIZE = (1 << 21) + 1;
char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c,
                                       qu[55];
int f, qr;
inline void flush() {
  fwrite(obuf, 1, oS - obuf, stdout);
  oS = obuf;
}
inline void putc(char x) {
  *oS++ = x;
  if (oS == oT) flush();
}
template <class I>
inline void gi(I &x) {
  for (f = 1, c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                              (iS == iT ? EOF : *iS++))
                            : *iS++);
       c < '0' || c > '9';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    if (c == '-') f = -1;
  for (x = 0; c <= '9' && c >= '0';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    x = (x << 1) + (x << 3) + (c & 15);
  x *= f;
}
template <class I>
inline void get(I &x) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 'A' || c > 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  x = c;
}
inline void read(char *s) {
  for (c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++);
       c < 'A' || c > 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    ;
  for (; c >= 'A' && c <= 'Z';
       c = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin),
                       (iS == iT ? EOF : *iS++))
                     : *iS++))
    *++s = c;
  *++s = '\0';
}
template <class I>
inline void print(I x) {
  if (!x) putc('0');
  if (x < 0) putc('-'), x = -x;
  while (x) qu[++qr] = x % 10 + '0', x /= 10;
  while (qr) putc(qu[qr--]);
}
struct Flusher_ {
  ~Flusher_() { flush(); }
} io_flusher_;
}  // namespace io
using io ::get;
using io ::gi;
using io ::print;
using io ::putc;
using io ::read;
const int N = 1e5 + 5, M = N * 6;
int pl[N], pr[N], a[N << 1], cnt[N << 1];
int tot = 1, head[M], nxt[M], adj[M], vis[M], col[M];
inline void addedge(register int x, register int y) {
  nxt[++tot] = head[x];
  adj[head[x] = tot] = y;
}
inline void dfs(register int x) {
  register int i;
  while (i = head[x])
    if (!vis[i])
      vis[i] = vis[i ^ 1] = 1, dfs(adj[i]), col[i / 2] = i & 1;
    else
      head[x] = nxt[i];
}
int main() {
  register int n, m, i;
  gi(n);
  m = 0;
  for (i = 1; i <= n; ++i)
    gi(pl[i]), gi(pr[i]), ++pr[i], a[++m] = pl[i], a[++m] = pr[i];
  sort(a + 1, a + 1 + m);
  m = unique(a + 1, a + 1 + m) - a - 1;
  for (i = 1; i <= n; ++i)
    pl[i] = lower_bound(a + 1, a + 1 + m, pl[i]) - a,
    pr[i] = lower_bound(a + 1, a + 1 + m, pr[i]) - a, addedge(pl[i], pr[i]),
    addedge(pr[i], pl[i]), ++cnt[pl[i]], --cnt[pr[i]];
  for (i = 1; i <= m; ++i) {
    cnt[i] += cnt[i - 1];
    if (cnt[i] & 1) addedge(i, i + 1), addedge(i + 1, i);
  }
  for (i = 1; i <= m; ++i) dfs(i);
  for (i = 1; i <= n; ++i) putc(col[i] ? '0' : '1'), putc(' ');
  putc('\n');
  return 0;
}