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 JAVA):

Solution:
import java.io.*;
import java.util.*;

public class R245qE {

	static int n;
	static TreeSet<Pair> set;
	static int ans[];
	static ArrayList<Integer> g[];
	
  	@SuppressWarnings("unchecked")
	public static void main(String args[]) {
		InputReader in = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
		
		n = in.nextInt();
		
		set = new TreeSet<Pair>();
		for(int i=1;i<=n;i++)
			set.add(new Pair(i,in.nextInt(),in.nextInt()));
		
		g = new ArrayList[n + 1];
		for(int i=1;i<=n;i++)
			g[i] = new ArrayList<Integer>();
		
		while(set.size() >= 2){
		//	System.out.println(set);
			Pair a = set.pollFirst();
			Pair b = set.pollFirst();
			if(a.y < b.x)
				set.add(b);
			else{
				//System.out.println(a.idx + " " + b.idx);
				g[a.idx].add(b.idx);
				g[b.idx].add(a.idx);
				if(a.y < b.y){
					b.x = a.y + 1;
					set.add(b);
				}
				else if(a.y > b.y){
					a.x = b.y + 1;
					set.add(a);
				}
			}
		}
		
		ans = new int[n + 1];
		Arrays.fill(ans, -1);
		ans[0] = 0;
		
		for(int i=1;i<=n;i++)
			if(ans[i] == -1)
				dfs(i,0);
		
		for(int i=1;i<=n;i++)
			w.print(ans[i] + " ");
		w.println();
		w.close();
	}
  	
  	static public void dfs(int curr,int color){
  		if(ans[curr] != -1){
  			if(ans[curr] != color)
  				System.out.println("here");
  			return;
  		}
  		ans[curr] = color;
  		color = 1 - color;
  		for(int x : g[curr])
  			dfs(x,color);
  	}
  	
	static class Pair implements Comparable<Pair>{
		int idx,x,y;
		Pair(int idx,int x,int y){
			this.idx = idx;
			this.x = x;
			this.y = y;
		}
		public int compareTo(Pair o){
			if(x != o.x)
				return Integer.compare(x, o.x);
			if(y != o.y)
				return Integer.compare(y, o.y);
			return Integer.compare(idx, o.idx);
		}
		public String toString(){
			return idx + " " + x + " " + y;
		}
	}
	
	static class InputReader {

		private InputStream stream;
		private byte[] buf = new byte[8192];
		private int curChar;
		private int snumChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream) {
			this.stream = stream;
		}

		public int snext() {
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) {
				curChar = 0;
				try {
					snumChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public int nextInt() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			int res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}
		
		public long nextLong() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = snext();
			}

			long res = 0;

			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = snext();
			} while (!isSpaceChar(c));

			return res * sgn;
		}
		
		public String readString() {
			int c = snext();
			while (isSpaceChar(c))
				c = snext();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = snext();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public boolean isSpaceChar(int c) {
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public interface SpaceCharFilter {
			public boolean isSpaceChar(int ch);
		}
	}
}