Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the people who haven't ranked in the top k in their semifinal but got to the n - 2k of the best among the others.

The tournament organizers hasn't yet determined the k value, so the participants want to know who else has any chance to get to the finals and who can go home.


-----Input-----

The first line contains a single integer n (1 ≤ n ≤ 10^5) — the number of participants in each semifinal.

Each of the next n lines contains two integers a_{i} and b_{i} (1 ≤ a_{i}, b_{i} ≤ 10^9) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifinals, correspondingly. All results are distinct. Sequences a_1, a_2, ..., a_{n} and b_1, b_2, ..., b_{n} are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.


-----Output-----

Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-th semifinal has any chances to advance to the finals, otherwise it should equal a "0".


-----Examples-----
Input
4
9840 9920
9860 9980
9930 10020
10040 10090

Output
1110
1100

Input
4
9900 9850
9940 9930
10000 10020
10060 10110

Output
1100
1100



-----Note-----

Consider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090.  If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals.  If k = 1, the winners from both semifinals move to the finals (with results 9840 and 9920), and the other places are determined by the time (these places go to the sportsmen who run the distance in 9860 and 9930 milliseconds).  If k = 2, then first and second places advance from each seminfial, these are participants with results 9840, 9860, 9920 and 9980 milliseconds.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
a = list(tuple(map(int,input().split())) for i in range(n))
#a.append(tuple(map(int,input().split())))
m = n // 2
c = list('1' for i in range(m))
d = list('1' for i in range(m))
#for i in range(n):print(a[i][0],a[i][1])
for i in range(m,n):
        if a[i][0] < a[n-i-1][1]:
            c.append('1')
        else:
            c.append('0')
        if a[n-i-1][0] > a[i][1]:
            d.append('1')
        else:
            d.append('0')
print(''.join(c))
print(''.join(d))


n = int(input())
p1=['0' for _ in range(n)]
p2=['0' for _ in range(n)]
t1=[]
t2=[]
for i in range(n):
    a, b = map(int, input().split())
    t1.append((a,i))
    t2.append((b,i))
t2.sort()
t1.sort()
for k in range((n//2)):
    p1[t1[k][1]]='1'
    p2[t2[k][1]]='1'
i=0
j=0
for k in range(n):
    if t1[i][0]<t2[j][0]:
        p1[t1[i][1]]='1'
        i+=1
    else:
        p2[t2[j][1]]='1'
        j+=1

print("".join(p1))
print("".join(p2))

__author__ = 'asmn'

n = int(input())
a = sorted((num, (j, i)) for i in range(n) for (j, num) in enumerate(map(int, input().split())))
mk = [['0'] * n, ['0'] * n]

for (k, (num, (j, i))) in enumerate(a):
    if (i + 1) * 2 <= n or (k + 1) <= n:
        mk[j][i] = '1'

print('\n'.join(''.join(ss) for ss in mk))



n = int(input())
a, b = [0] * n, [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())
k = n // 2
i = j = k - 1
if 2 * k < n:
    if a[k] < b[k]: i, j = k, k - 1
    else: i, j = k - 1, k
x, y = i + 1, j
while x < n and y >= 0 and a[x] < b[y]:
    x += 1
    y -= 1
u, v = i, j + 1
while u >= 0 and v < n and a[u] > b[v]:
    u -= 1
    v += 1
i, j = max(i, x), max(j, v)
print('1' * i + '0' * (n - i))
print('1' * j + '0' * (n - j))

n=int(input())
a=[]
b=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
i=j=0
ans1=['0']*n
ans2=['0']*n
for k in range(n):
    if a[i]<b[j]: 
        ans1[i]='1'
        i+=1
    else: 
        ans2[j]='1'
        j+=1
for i in range(n//2):
    ans1[i]=ans2[i]='1'
for i in range(n): print(ans1[i],end='')
print()
for i in range(n): print(ans2[i],end='')
print()


n = int(input())
sem1 = []
sem2 = []
l = [0,0]
for cont in range(0,n):
    l = list(map(int, input().split()))
    sem1.append(l[0])
    sem2.append(l[1])

kmax = int(n/2)
max1 = 0
max2 = 0

for cont in range(0,n):
    if sem1[max1] < sem2[max2]:
        max1 += 1
    else:
        max2 += 1

ris1 = ['1']*(max([max1,kmax]))
ris2 = ['1']*max([max2,kmax])
ris1 = ris1 + ['0']*(n-len(ris1))
ris2 = ris2 + ['0']*(n-len(ris2))

print(''.join(ris1))
print(''.join(ris2))

# -*- coding: utf-8 -*-

n = int(input())
a, b = [], []
for i in range(n):
    x, y = list(map(int, input().split()))
    a.append(x)
    b.append(y)
    
p = q = 0
c = 0
while c < n:
    if a[p] < b[q]:
        #print('{}<{}'.format(a[p], a[q]))
        p += 1
    else:
        #print('{}>{}'.format(a[p], a[q]))
        q += 1
    c += 1

p0 = max(p, n//2)
print('1'*p0 + '0'*(n-p0))
q0 = max(q, n//2)
print('1'*q0 + '0'*(n-q0))


n = int(input())
a, b = zip(*(map(int, input().split()) for _ in range(n)))
i = j = 0
while i < n and j < n and i + j < n:
  if a[i] < b[j]:
    i += 1
  else:
    j += 1
p = lambda x: ("1" * max(n // 2, x)).ljust(n, "0")
print(p(i))
print(p(j))

n = int(input())

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

ans = ''
for i in range(n):
    if i < n//2 or a[i] < b[n-1-i]:
        ans += '1'
    else:
        ans += '0'

ans += '\n'

for i in range(n):
    if i < n//2 or b[i] < a[n-1-i]:
        ans += '1'
    else:
        ans += '0'

print(ans)


n = int(input())
inp = []
for i in range(n):
    inp1,inp2 = input().split(" ")
    inp.append([int(inp1),1]), inp.append([int(inp2),2])

result1,result2,result3 = "","",""
j = 0
inp.sort()
inpSort = inp
# k = 0

for i in inpSort:
    if j == n: break
    if i[1] == 1: result1 += "1"
    else : result2 += "1"
    j+=1
# k = n//2

for i in range(n//2):
    result3 += "1"

if len(result1) > len(result3):
    for i in range(n-len(result1)):
        result1+="0"
    for i in range(n-len(result3)):
        result3+="0"
    result = result1 + "\n" + result3
elif len(result2) > len(result3):
    for i in range(n-len(result2)):
        result2+="0"
    for i in range(n-len(result3)):
        result3+="0"
    result = result3 + "\n" + result2
else:
    for i in range(n-len(result3)):
        result3+="0"
    result = result3 + "\n" + result3

print(result)

a = int(input())
pol1 = []
pol2 = []
for i in range(a):
    x, y = map(int, input().split())
    pol1.append(x)
    pol2.append(y)
f = 0
s = 0
ans1 = [0] * a
ans2 = [0] * a
count = 0
while True:
    count += 1
    if pol1[f] < pol2[s]:
        ans1[f] = 1
        f += 1
    else:
        ans2[s] = 1
        s += 1
    if count == a:
        break
for i in range(a // 2):
    ans1[i] = 1
    ans2[i] = 1
s = ''
for i in ans1:
    s += str(i)
print(s)
s = ''
for i in ans2:
    s += str(i)
print(s)

n = int(input())
A, B = [], []
p = q = 0
k = n//2

for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

for i in range(n):
    if A[p] < B[q]:
        p += 1
    else:
        q += 1

for i in range(n):
        print(1 if i < p or i < k else 0, end='')
print()
for i in range(n):
        print(1 if i < q or i < k else 0, end='')
print()


team1 = [0 for i in range(100007)]
team2 = [0 for i in range(100007)]

n = int(input())

for i in range(1, n+1):
    line = input().split()
    team1[i] = int(line[0])
    team2[i] = int(line[1])

for i in range(1, n+1):
    if i <= n // 2 or team1[i] < team2[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()

for i in range(1, n+1):
    if i <= n // 2 or team2[i] < team1[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()


team1 = [-1]
team2 = [-1]

n = int(input())

for i in range(n):
    line = input().split()
    team1.append(int(line[0]))
    team2.append(int(line[1]))

for i in range(1, n+1):
    if i <= n // 2 or team1[i] < team2[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()

for i in range(1, n+1):
    if i <= n // 2 or team2[i] < team1[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()


n = int(input())
a, b = zip(*(map(int, input().split()) for _ in range(n)))
i = j = 0
while i < n and j < n and i + j < n:
  if a[i] < b[j]:
    i += 1
  else:
    j += 1
p = lambda x: ("1" * max(n // 2, x)).ljust(n, "0")
print(p(i))
print(p(j))

def semifinals(l1,l2):
    output1=[0]*len(l1)
    output2=[0]*len(l2)
    n=len(l1)
    k = len(l1)//2
    output1[0:k]=[1]*k
    output2[0:k]=[1]*k
    i = k
    while i < len(l1):
        if l1[i]<l2[n-i-1]:
            output1[i]=1
        if l2[i]<l1[n-i-1]: # xet tuong tu voi l2[i] va l1[n - 1 - i]
            output2[i]=1
        i+=1
    output1=''.join([str(x) for x in output1])
    output2=''.join([str(x) for x in output2])
    return (output1,output2)
n=int(input())
l1=[]
l2=[]
for i in range(n):
    a = [int(x) for x in input().split()]
    l1.append(a[0])
    l2.append(a[1])
print(semifinals(l1,l2)[0])
print(semifinals(l1,l2)[1])


def semifinals(l1,l2):
    output1=[0]*len(l1)
    output2=[0]*len(l2)
    n=len(l1)
    k = len(l1)//2
    output1[0:k]=[1]*k
    output2[0:k]=[1]*k
    i = k
    while i < len(l1):
        if l1[i]<l2[n-i-1]:
            output1[i]=1
        if l2[i]<l1[n-i-1]: 
            output2[i]=1
        i+=1
    output1=''.join([str(x) for x in output1])
    output2=''.join([str(x) for x in output2])
    return (output1,output2)
n=int(input())
l1=[]
l2=[]
for i in range(n):
    a = [int(x) for x in input().split()]
    l1.append(a[0])
    l2.append(a[1])
print(semifinals(l1,l2)[0])
print(semifinals(l1,l2)[1])


# n = 4
# semi1 = [0, 9900, 9940, 10000, 10060]
# semi2 = [0, 9850, 9930, 10020, 10110]
n = int(input())
semi1 = [0] * (n + 1)
semi2 = [0] * (n + 1)

for i in range(1, n + 1):
    semi1[i], semi2[i] = map(int, input().split())

semi1Selected = [0] * (n + 1)
semi2Selected = [0] * (n + 1)


for i in range(1, n + 1):
    if i <= n // 2:
        semi1Selected[i] = 1
        semi2Selected[i] = 1
    else:
        if semi1[i] < semi2[n - i + 1]:
            semi1Selected[i] = 1

        if semi2[i] < semi1[n - i + 1]:
            semi2Selected[i] = 1


for i in range(1, n + 1):
    print(semi1Selected[i], end="")
print()
for i in range(1, n + 1):
    print(semi2Selected[i], end="")


n = int(input())

team1 = [0 for i in range(n+7)]
team2 = [0 for i in range(n+7)]
for i in range(1, n+1):
    line = input().split()
    team1[i] = int(line[0])
    team2[i] = int(line[1])

for i in range(1, n+1):
    if i <= n // 2 or team1[i] < team2[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()

for i in range(1, n+1):
    if i <= n // 2 or team2[i] < team1[n-i+1]:
        print(1, end = '')
    else:
        print(0, end = '')
print()

n = int(input())
a = []
b = []
for i in range (n):
    pair = input().split()
    a.append(int(pair[0]))
    b.append(int(pair[1]))
flag = 0
for i in range (n):
    if (i < n // 2):
        print('1', end = '')
    else:
        if (flag == 0 and a[i] >= b[n - i - 1]):
            flag = 1
        if (flag == 0):
            print('1', end = '')
        else:
            print('0', end = '')
print()
flag = 0
for i in range (n):
    if (i < n // 2):
        print('1', end = '')
    else:
        if (flag == 0 and b[i] >= a[n - i - 1]):
            flag = 1
        if (flag == 0):
            print('1', end = '')
        else:
            print('0', end = '')