There are $n$ segments $[l_i, r_i]$ for $1 \le i \le 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 \le T \le 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 \le n \le 10^5$) — number of segments. It is guaranteed that $\sum{n}$ over all queries does not exceed $10^5$.

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


-----Output-----

For each query print $n$ integers $t_1, t_2, \dots, t_n$ ($t_i \in \{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.

Starter code:

Solutions:
t = int(input())

for ti in range(t):
	n = int(input())

	lri = [None for _ in range(n)]

	for _ in range(n):
		li, ri = list(map(int, input().split()))
		lri[_] = (li, ri, _)

	lri.sort()

	t = [None for _ in range(n)]

	ct, t[lri[0][2]], eg = 1, 1, lri[0][1]

	for i in range(1, n):
		if lri[i][0] <= eg:
			t[lri[i][2]] = ct
			eg = max(eg, lri[i][1])
		else:
			ct = 3 - ct
			t[lri[i][2]] = ct
			eg = lri[i][1]

	if all(ti == 1 for ti in t):
		print(-1)
	else:
		print(*t)


def ii():
    return int(input())
def mi():
    return list(map(int, input().split()))
def li():
    return list(mi())

for _ in range(ii()):
    n = ii()
    a = [(li() + [i]) for i in range(n)]
    a.sort()
    ans = [2] * n
    pr = a[0][0]
    for l, r, i in a:
        if l > pr:
            break
        ans[i] = 1
        pr = max(pr, r)
    if 2 in ans:
        print(*ans)
    else:
        print(-1)


t = int(input())
for i in range(t):
    n = int(input())
    sobs = []
    for j in range(n):
        a, b = list(map(int, input().split()))
        sobs.append([[a, -1], j])
        sobs.append([[b, 1], j])
    sobs.sort()
    counts = 0
    passed = []
    success = []
    alls = [0 for q in range(n)]
    succeed = False
    for sob in sobs:
        if succeed:
            if sob[0][1] == -1:
                pass
            else: 
                success.append(sob[1])
            continue
        if sob[0][1] == -1:
            counts += 1
        else:
            counts -= 1
            passed.append(sob[1])
            if counts == 0:
                succeed = True
    if succeed and success:
        for a in passed:
            alls[a] = 1
        for b in success:
            alls[b] = 2
        print(*alls)
    else:
        print(-1)


T=int(input())
for i in range(0,T):
    n=int(input())
    L=[]
    dp=[0]*n
    for j in range(0,n):
        l,r=map(int,input().split())
        L.append((l,r,j))
    L=sorted(L)
    temp=-1
    ed=L[0][1]
    for j in range(1,len(L)):
        if(L[j][0]>ed):
            temp=j
            break
        ed=max(ed,L[j][1])
    if(temp==-1 or n==1):
        print(-1)
    else:
        for j in range(0,len(L)):
            if(j<temp):
                dp[L[j][2]]=1
            else:
                dp[L[j][2]]=2
        for j in range(0,n):
            print(dp[j],end=" ")
        print(" ")
        
        


for _ in range(int(input())):
	n=int(input())
	a=[]
	f=0
	for i in range(n):
		l,r=map(int,input().split())
		a.append([l,r,i])
	a.sort(key=lambda x:x[0])
	rm=a[0][1]
	for i in range(n):
		if a[i][0]>rm:
			b=a[i]
			f=1
			break
		if a[i][1]>rm:
			rm=a[i][1]
	if f==0:
		print(-1)
	else:
		a.sort(key=lambda x:x[2])
		for i in range(n):
			if a[i][0]<b[0]:
				print(1,end=" ")
			else:
				print(2,end=" ")
	print()


T = int(input())

for i in range(T):
    n = int(input())
    X = []
    for j in range(n):
        l, r = list(map(int, input().split()))
        X.append([j, l, r])

    X = sorted(X, key = lambda x: x[1])
    # print(X)
    
    Y = ["2"] * n
    s = -1
    rmax = X[0][2]
    Y[X[0][0]] = "1"
    for i in range(1, n):
        if X[i][1] > rmax:
            s = i
            break
        rmax = max(rmax, X[i][2])
        Y[X[i][0]] = "1"
        
    if s < 0:
        print(-1)
    else:
        print(" ".join(Y))



for c in range(int(input())):
    N = int(input())
    counter = 0
    segments = []
    for n in range(N):
        l, r = map(int, input().split())
        segments.append([[l, r], counter])
        counter += 1
    
    segments.sort()
    ans = [-1] * N
    
    rightBound = segments[0][0][1]
    valid = -1
    for i in range(1, len(segments)):
        if segments[i][0][0] > rightBound:
            valid = i
            break
        else:
            rightBound = max(rightBound, segments[i][0][1])
    
    if valid == -1:
        print(-1)
    else:
        for i in range(valid):
            ans[segments[i][1]] = 1
        for i in range(valid, len(segments)):
            ans[segments[i][1]] = 2
    
        for a in ans:
            print(a, end= ' ') 
    print()
'''
3
2
5 5
2 3
3
3 5
2 3
2 3
3
3 3
4 4
5 5
'''    

MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))

t, = I()
while t:
    t -= 1
    n, = I()
    a = [2]*(n)
    l = []
    for i in range(n):
        l.append(I()+[i])
    l.sort()
    mn = l[0][0]
    mx = l[0][1]
    i = 0
    while i < n and l[i][0] <= mx:
        mx = max(mx, l[i][1])
        a[l[i][2]] = 1
        i += 1
    if all([i == 1 for i in a]) or all([i == 2 for i in a]):
        print(-1)
    else:
        print(*a)

t = int(input())
for tc in range(t):
    n = int(input())
    l = []

    for i in range( n ):
        a,b = map(int,input().split())
        l.append([i,a,b])

    l = sorted(l, key=lambda x: x[1])
    last = l[0][1]
    i = 0
    while i < n:
        if l[ i ][ 1 ] > last:
            break
        last = max( last, l[ i ][ 2 ] )
        i += 1

    if i == n:
        print( -1 )
    else:
        ind = [2] * n
        for j in range( i ):
            ind[ l[ j ][ 0 ] ] = 1
        for i in ind:
            print( i,end=' ')
        print("")


t = int(input())
final = []
for k in range(t):
    n = int(input())
    skl = []
    for i in range(n):
        a, b = map(int, input().split())
        skl.append((a, -1, i))
        skl.append((b, 1, i))
    skl.sort()
    m = 0
    ans = ['0']*n
    for i, p in enumerate(skl):
        if m == 0 and i != 0:
            for j in range(i, 2*n):
                ans[skl[j][2]] = '2'
            break

        m -= p[1]
        if p[1] == -1:
            ans[skl[i][2]] = '1'
    if not '2' in ans:
        final.append('-1')
    else:
        final.append(' '.join(ans))
print('\n'.join(final))

def check(data):
    n = len(data)
    s = sorted(zip(data, range(n)))
    m = s[0][0][1]
    left = set()
    for i, r in enumerate(s):
        left.add(r[1])
        if i == len(s)-1:
            return '-1'
        m = max(m, r[0][1])
        if s[i+1][0][0] > m:
            break
    res = ['1' if j in left else '2' for j in range(n)]
    return ' '.join(res)


T = int(input())
for i in range(T):
    n = int(input())
    data = []
    for j in range(n):
        l, r = map(int, input().split())
        data.append((l, r))
    print(check(data))

T = int(input())

for _ in range(T):
    n = int(input())
    seg = []
    for s in range(n):
        l,r = [int(x) for x in input().split()]
        seg.append((l,r))
    pos = {}
    for i in range(n):
        if seg[i] in pos:
            pos[seg[i]].append(i)
        else:
            pos[seg[i]] = [i]
    seg.sort()
    right = seg[0][1]
    goodindex = -1
    for j in range(1,n):
        if seg[j][0] > right:
            goodindex = j
            break
        right = max(right,seg[j][1])
    if goodindex == -1:
        print(-1)
    else:
        ans = ['2']*n
        for i in range(goodindex):
            ans[pos[seg[i]][-1]] = '1'
            pos[seg[i]].pop()
        print(' '.join(ans))

import sys
input = sys.stdin.readline

Q=int(input())

for test in range(Q):
    n=int(input())
    LR=[list(map(int,input().split()))+[i] for i in range(n)]
    LR.sort()

    GR1=[LR[0][0],LR[0][1]]

    for i in range(1,n):
        l,r,_=LR[i]

        if r<GR1[0] or l>GR1[1]:
            ANS=i
            break
        else:
            GR1=[min(GR1[0],l),max(GR1[1],r)]

    else:
        print(-1)
        continue

    ANSLIST=[1]*n
    for j in range(ANS,n):
        ANSLIST[LR[j][2]]=2

    for a in ANSLIST:
        print(a,end=" ")
    print()



L = 0
R = 1

def main():
    buf = input()
    T = int(buf)
    n = []
    lr = []
    for i in range(T):
        buf = input()
        n.append(int(buf))
        lr.append([])
        for j in range(n[i]):
            buf = input()
            buflist = buf.split()
            lr[i].append([int(buflist[0]), int(buflist[1])])
    for i in range(T):
        lr_s = list(sorted(lr[i]))
        threshold = lr_s[0][R]
        threshold_final = None
        for j in range(1, n[i]):
            if threshold < lr_s[j][L]:
                threshold_final = threshold
                break
            elif threshold < lr_s[j][R]:
                threshold = lr_s[j][R]
        if threshold_final == None:
            print(-1) # impossible
            continue
        answer = ""
        for j in range(n[i]):
            if lr[i][j][L] <= threshold_final:
                answer += "1"
            else:
                answer += "2"
            if j < n[i] - 1:
                answer += " "
        print(answer)

def __starting_point():
    main()

__starting_point()

T = int(input())
for i in range(T):
    n = int(input())
    inp=[]
    temp = []
    for j in range(n):
        a,b = [int(u) for u in input().split()]
        inp.append([a,b])
        temp.append([a,b])
    inp.sort()
    check=0
    begin = inp[0][0]
    end = inp[0][1]
    for j in range(n):
        if(inp[j][0]>end):
            check=1
            break
        if(inp[j][1]>end):
            end = inp[j][1]
    ans = []
    if(check==0):
        print(-1)
    else:
        for j in range(n):
            if(temp[j][0]>=begin and temp[j][1]<=end):
                ans.append("1")
            else:
                ans.append("2")
        print(" ".join(ans))


q=int(input())

for i in range(q):
    
    n=int(input())
    ilist=[]
    for j in  range(n):
        ilist.append(list(map(int, input().rstrip().split())))
        ilist[j].append(j)
    ilist.sort()
    
    seglist=[2]*n
    seglist[ilist[0][2]]=1
    #print(seglist)
    #print(ilist)
    #print(ilist)
    goodvalue=-1
    currentmax=ilist[0][1]
    for k in range(n-1):
        if currentmax>=ilist[k+1][0]:
            seglist[ilist[k+1][2]]=1
            currentmax=max([currentmax,ilist[k+1][1]])
        if currentmax<ilist[k+1][0]:
            break
            
    #for k in range(goodvalue+1,n):        
    #    seglist[ilist[k][2]]=2    
    #    print(k)
    #print(seglist)    
    if sum(seglist)==n:
        print(-1)
    else:
        print(*seglist)

n = int(input())

for t in range(n):

    k = int(input())
    samples = []
    for i in range(k):
        samples.append(tuple(map(int, input().split())))

    samples = sorted(enumerate(samples), key=lambda x: x[1])

    tick = 1
    ans = [1]
    group_end = samples[0][1][1]

    for si in range(1, len(samples)):
        now = samples[si][1]
        if now[0] > group_end:
            tick = 2
        else:
            group_end = max(now[1], group_end)
            ans.append(1)
        if tick == 2:
            ans.extend([2] * (len(samples) - si))
            break

    ans = sorted(zip(samples, ans))
    ans = list([x[1] for x in ans])
    if 2 not in ans:
        print(-1)
    else:
        print(' '.join(map(str, ans)))



import math


def is_intersect(l1, r1, l2, r2):
    return (l1 < l2 and r1 >= l2) or (l1 >= l2 and l1 <= r2)


def get_groups(ranges):
    ranges.sort(key=lambda x: x[1])
    ranges.sort(key=lambda x: x[0])
    ranges[0][3] = 1
    group1 = ranges[0][:2]
    group2 = None
    for i, rng in enumerate(ranges[1:]):
        l, r = rng[:2]
        if is_intersect(l, r, *group1) and ((group2 is None) or not is_intersect(l, r, group2)):
            rng[3] = 1
            group1[0] = min(group1[0], l)
            group1[1] = max(group1[1], r)
        elif not is_intersect(l, r, *group1):
            if group2 is None:
                group2 = [l, r]
            else:
                group2[0] = min(group2[0], l)
                group2[1] = max(group2[1], r)
            rng[3] = 2
        else:
            return -1
    if group2 is None:
        return -1
    ranges.sort(key=lambda x: x[2])
    return ' '.join(list(map(str, (rng[3] for rng in ranges))))



def __starting_point():
    n = int(input())
    for i in range(n):
        k = int(input())
        arr = [None] * k
        for j in range(k):
            arr[j] = list(map(int, input().split())) + [j, -1]
        print(get_groups(arr))

__starting_point()

q=int(input())
for i in range(q):
	n=int(input())
	arr=[0 for i in range(n)]
	for i in range(n):
		temp=list(map(int,input().split()))
		temp.append(i)
		arr[i]=temp
	arr=sorted(arr,key=lambda l:l[0])
	#print(arr)
	ans=[1 for i in range(n)]
	# if(arr[0][1]<arr[1][0]):
	# 	ans[0]=2
	# 	for i in range(n):
	# 		print(ans[i],end=' ')
	# 	print()
	# 	continue
	# if(arr[n-1][0]>arr[n-2][1]):
	# 	ans[n-1]=2
	# 	for i in range(n):
	# 		print(ans[i],end=' ')
	# 	print()
	# 	continue
	yoyo=-1
	maxa=arr[0][1]
	for i in range(1,n):
		if(arr[i][0]>maxa):
			yoyo=i
			break
		if(arr[i][1]>maxa):
			maxa=arr[i][1]
	if(yoyo==-1):
		print(-1)
		continue
	else:
		for i in range(yoyo,n):
			ans[arr[i][2]]=2
	for i in range(n):
		print(ans[i],end=' ')
	print()


T = int(input())
for _ in range(T):
    n = int(input())
    events = []
    results = [0 for i in range(n)]
    fail = False
    for i in range(n):
        l, r = map(int, input().split())
        events.append((l, 0, i))
        events.append((r, 1, i))

    events.sort()
    cnt = 0
    cur_seg = 1
    for _, t, i in events:
        if t == 0:
            cnt += 1
            results[i] = cur_seg
        else:
            cnt -= 1

        if cnt == 0:
            cur_seg = 1 + cur_seg % 2

    if len(set(results)) == 2:
        print(*results)
    else:
        print(-1)

q = int(input())
while q > 0:
    q = q-1
    L = []
    n = int(input())
    for i in range(n):
        L.append(tuple(map(int, input().split())))
    d = {}
    ind = 0
    for i in L:
        if i not in d:
            d[i] = []
        d[i].append(ind)
        ind += 1
    S = sorted(L)
    r = S[0][1]
    i = 1
    while i < n:
        if S[i][0] > r:
            break
        r = max(r,S[i][1])
        i += 1
    #print(S,i)
    if i == n:
        print(-1)
    else:
        while i < n:
            d[S[i]].append(-2)
            i += 1
        for i in L:
            if d[i][-1] == -2:
                print(2,end=' ')
            else:
                print(1,end=' ')
        print()

T = int(input())
for _ in range(T):
    n = int(input())
    s = []
    for k in range(n):
        l, r = [int(i) for i in input().split()]
        s.append([l, 1, k])
        s.append([r, 2, k])
    s.sort()
    u = [2] * n
    o = set()
    for i in s:
        u[i[2]] = 1
        if i[2] not in o:
            o.add(i[2])
        else:
            o.remove(i[2])
        if not o:
            if i != s[-1]:
                print(*u)
                break
    else:
        print(-1)


t = int(input())

for test in range(t):
    n = int(input())
    ans = ['1' for i in range(n)]

    start, end = dict(), dict()
    for i in range(n):
        a, b = list(map(int, input().split()))
        if a in start:
            start[a].append(i + 1)
        else:
            start[a] = [i + 1]

        if (i + 1) in end:
            end[i + 1].append(b)
        else:
            end[i + 1] = [b]

    st_sorted = sorted(list(start.keys()))

    m = 0
    ok = False
    ans_pos = -1
    for pos in range(len(st_sorted) - 1):
        for i in start[st_sorted[pos]]:
            m = max(m, max(end[i]))
        if m < st_sorted[pos + 1]:
            ok = True
            ans_pos = pos
            break
    if ok:
        for i in range(pos + 1, len(st_sorted)):
            for pos in start[st_sorted[i]]:
                ans[pos - 1] = '2'
        print(' '.join(ans))
    else:
        print(-1)