Problem: There are n segments [l_i, r_i] for 1 ≤ i ≤ n. You should divide all segments into two non-empty groups in such way that there is no pair of segments from different groups which have at least one common point, or say that it's impossible to do it. Each segment should belong to exactly one group.

To optimize testing process you will be given multitest.

Input

The first line contains one integer T (1 ≤ T ≤ 50000) — the number of queries. Each query contains description of the set of segments. Queries are independent.

First line of each query contains single integer n (2 ≤ n ≤ 10^5) — number of segments. It is guaranteed that ∑{n} over all queries does not exceed 10^5.

The next n lines contains two integers l_i, r_i per line (1 ≤ l_i ≤ r_i ≤ 2 ⋅ 10^5) — the i-th segment.

Output

For each query print n integers t_1, t_2, ..., t_n (t_i ∈ \{1, 2\}) — for each segment (in the same order as in the input) t_i equals 1 if the i-th segment will belongs to the first group and 2 otherwise.

If there are multiple answers, you can print any of them. If there is no answer, print -1.

Example

Input


3
2
5 5
2 3
3
3 5
2 3
2 3
3
3 3
4 4
5 5


Output


2 1 
-1
1 1 2 

Note

In the first query the first and the second segments should be in different groups, but exact numbers don't matter.

In the second query the third segment intersects with the first and the second segments, so they should be in the same group, but then the other group becomes empty, so answer is -1.

In the third query we can distribute segments in any way that makes groups non-empty, so any answer of 6 possible is correct.

Solution (in JAVA):

Solution:


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class q54 {
	static final int EPS = (int) 1e-9;

	public static void main(String[] args) throws IOException {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int q = sc.nextInt();
			TreeMap<pair, Integer> tm = new TreeMap<>();
			pair[] x = new pair[q];
			int y [] = new int [q];
			
			for (int j = 0; j < q; j++) {
				x[j] = new pair(sc.nextInt(), sc.nextInt(),j);
				tm.put(x[j], j);
			}
			Arrays.sort(x);
//			for(int j=0;j<q;j++) {
//				System.out.println(x[j].l+" "+x[j].r);
//			}
			int gap = 0;
			int last=0;
			int max=-1;
			for (int j = 0; j < q-1; j++) {
                if(j==0) {
                	max = x[j].r;
                } 
				if(max<x[j+1].l) {
                	 gap=1;
                     break;
				}
				else{
					max = Math.max(max,x[j+1].r);
					last=j+1;
				}
			}
			
			if(gap==0) {
				System.out.println(-1);
				continue;
			}
			
			for(int j=0;j<q;j++) {
				int idx = tm.get(x[j]);				
				if(j<=last) {
					y[idx]=1;
				}else {
					y[idx]=2;
				}
			}
			StringBuilder sb = new StringBuilder();
			for(int j=0;j<y.length;j++) {
				sb.append(y[j]+" ");
			}
			System.out.println(sb.toString());
			
		}

	}

	public static class pair implements Comparable<pair> {
		int l, r, idx;

		pair(int l, int r, int idx) {
			this.l = l;
			this.r = r;
			this.idx=idx;
		}

		public int compareTo(pair p) {
			if (Math.abs(l - p.l) > EPS)
				return l > p.l ? 1 : -1;
			if (Math.abs(r - p.r) > EPS)
				return r > p.r ? 1 : -1;
			if (Math.abs(idx - p.idx) > EPS)
				return idx > p.idx ? 1 : -1;
			return 0;
		}
	}

	public static class SegmentTree { // 1-based DS, OOP

		int N; // the number of elements in the array as a power of 2 (i.e. after padding)
		boolean[] array, sTree, lazy;

		SegmentTree(boolean[] in) {
			array = in;
			N = in.length - 1;
			sTree = new boolean[N << 1]; // no. of nodes = 2*N - 1, we add one to cross out index zero
			lazy = new boolean[N << 1];
			// build(1,1,N);
		}

		// void build(int node, int b, int e) // O(n)
		// {
		// if(b == e)
		// sTree[node] = array[b];
		// else
		// {
		// int mid = b + e >> 1;
		// build(node<<1,b,mid);
		// build(node<<1|1,mid+1,e);
		// sTree[node] = sTree[node<<1]+sTree[node<<1|1];
		// }
		// }
		//

		void update_point(int index, boolean val) // O(log n)
		{
			index += N - 1;
			sTree[index] |= val;
			while (index > 1) {
				index >>= 1;
				sTree[index] = sTree[index << 1] || sTree[index << 1 | 1];
			}
		}

		void update_range(int i, int j, boolean val) // O(log n)
		{
			update_range(1, 1, N, i, j, val);
		}

		void update_range(int node, int b, int e, int i, int j, boolean val) {
			if (i > e || j < b)
				return;
			if (b >= i && e <= j) {
				sTree[node] |= val;
				lazy[node] |= val;
			} else {
				int mid = b + e >> 1;
				propagate(node, b, mid, e);
				update_range(node << 1, b, mid, i, j, val);
				update_range(node << 1 | 1, mid + 1, e, i, j, val);
				sTree[node] = sTree[node << 1] | sTree[node << 1 | 1];
			}

		}

		void propagate(int node, int b, int mid, int e) {
			lazy[node << 1] |= lazy[node];
			lazy[node << 1 | 1] |= lazy[node];
			sTree[node << 1] |= lazy[node];
			sTree[node << 1 | 1] |= lazy[node];
			lazy[node] = false;
		}

		// int query(int i, int j)
		// {
		// return query(1,1,N,i,j);
		// }
		//
		// int query(int node, int b, int e, int i, int j) // O(log n)
		// {
		// if(i>e || j <b)
		// return 0;
		// if(b>= i && e <= j)
		// return sTree[node];
		// int mid = b + e >> 1;
		// propagate(node, b, mid, e);
		// int q1 = query(node<<1,b,mid,i,j);
		// int q2 = query(node<<1|1,mid+1,e,i,j);
		// return q1 + q2;
		//
		// }
	}

	static int[] shuffle(int[] a) {
		int n = a.length;
		for (int i = 0; i < n; i++) {
			int r = i + (int) (Math.random() * (n - i));
			int tmp = a[i];
			a[i] = a[r];
			a[r] = tmp;
		}
		return a;
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public long nextlong() throws IOException {
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			long res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if (x.charAt(0) == '-') {
				neg = true;
				start++;
			}
			for (int i = start; i < x.length(); i++)
				if (x.charAt(i) == '.') {
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				} else {
					sb.append(x.charAt(i));
					if (dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg ? -1 : 1);
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}