#include <cstdio>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const int knmax = 401337;
class edg{
public:
int x, y, color;
edg(){};
edg(int a1, int a2){
x = a1;
y = a2;
color = -1;
}
int nbr(int x1){
if(x == x1)
return y;
return x;
}
};
vector<int> g[knmax];
vector<edg> t;
int evis[knmax * 5], nvis[knmax];
vector<int> ans;
void dfs(int x){
nvis[x] = 1;
for(int i = 0; i < g[x].size(); ++i)
if(!evis[g[x][i]]){
evis[g[x][i]] = 1;
dfs(t[g[x][i]].nbr(x));
}
ans.push_back(x);
}
class seg{
public:
int x, y;
seg(){};
seg(int x1, int y1){
x = x1;
y = y1;
}
};
int nAt, nSg;
seg gv[knmax];
vector<int> atomz;
class hdata{
public:
int x, y, num;
hdata(){};
hdata(int x1, int y1, int n1){
x = x1;
y = y1;
num = n1;
}
bool operator ==(hdata other){
return x == other.x && y == other.y;
}
};
const int kmod = 666013, kp1 = 29, kp2 = 37;
vector<hdata> h[kmod];
int make_key(int x, int y){
return (x * kp1 + y * kp2) % kmod;
}
void insert(hdata x){
int key = make_key(x.x, x.y);
h[key].push_back(x);
}
void color(int x, int y, int col){
hdata now(x, y, 1337);
int key = make_key(x, y);
for(int i = 0; i < h[key].size(); ++i)
if(h[key][i] == now){
t[h[key][i].num].color = col;
swap(h[key].back(), h[key][i]);
h[key].pop_back();
return;
}
}
int deg[knmax];
void new_edge(int x, int y){
t.push_back(edg(x, y));
g[x].push_back(t.size() - 1);
g[y].push_back(t.size() - 1);
++deg[y];
++deg[x];
insert(hdata(x, y, (int)t.size() - 1));
}
void make_edges(){
for(int i = 1; i <= nSg; ++i){
int a, b;
int l = 0, r = nAt, mid, last;
while(l <= r){
mid = (l + r) / 2;
if(atomz[mid] > gv[i].x)
r = mid - 1;
else{
l = mid + 1;
last = mid;
}
}
a = last;
l = 0;r = nAt;
while(l <= r){
mid = (l + r) / 2;
if(atomz[mid] > gv[i].y)
r = mid - 1;
else{
l = mid + 1;
last = mid;
}
}
b = last;
new_edge(a, b + 1);
}
}
void get_nodes(){
scanf("%d", &nSg);
set<int> ends;
for(int i = 1; i <= nSg; ++i){
scanf("%d%d", &gv[i].x, &gv[i].y);
ends.insert(gv[i].x);
ends.insert(gv[i].y + 1);
}
atomz.push_back(-1e9);
for(set<int>::iterator it = ends.begin(); it != ends.end(); ++it)
atomz.push_back(*it);
atomz.push_back(1e9);
nAt = atomz.size() - 1;
make_edges();
vector<int> unp;
for(int i = 1; i <= nAt; ++i)
if(deg[i] & 1)
unp.push_back(i);
int u = 200042;
for(int i = 0; i < unp.size(); i += 2){
new_edge(unp[i], u);
new_edge(unp[i + 1], u);
++u;
}
}
void color_edges(){
for(int i = 1; i < ans.size(); ++i){
int x = ans[i - 1];
int y = ans[i];
if(x > y)
color(y, x, 0);
else
color(x, y, 1);
}
}
void output_colors(){
for(int i = 0; i < nSg; ++i)
printf("%d ", t[i].color);
}
int main(){
#ifndef ONLINE_JUDGE
freopen("E.in", "r", stdin);
freopen("E.out", "w", stdout);
#endif
get_nodes();
for(int i = 1; i <= nAt; ++i)
if(!nvis[i]){
ans.clear();
dfs(i);
color_edges();
}
output_colors();
return 0;
}
I2luY2x1ZGUgPGNzdGRpbz4KI2luY2x1ZGUgPGZzdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxxdWV1ZT4KI2luY2x1ZGUgPHNldD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBpbnQga25tYXggPSA0MDEzMzc7CgpjbGFzcyBlZGd7CnB1YmxpYzoKICBpbnQgeCwgeSwgY29sb3I7CgogIGVkZygpe307CgogIGVkZyhpbnQgYTEsIGludCBhMil7CiAgICB4ID0gYTE7CiAgICB5ID0gYTI7CiAgICBjb2xvciA9IC0xOwogIH0KCiAgaW50IG5icihpbnQgeDEpewogICAgaWYoeCA9PSB4MSkKICAgICAgcmV0dXJuIHk7CiAgICByZXR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