AtCoder Grand Contest 007 - Construct Sequences

You are given a permutation p of the set {1, 2, ..., N}. Please construct two sequences of positive integers a_1, a_2, ..., a_N and b_1, b_2, ..., b_N satisfying the following conditions:

* 1 \leq a_i, b_i \leq 10^9 for all i
* a_1 < a_2 < ... < a_N
* b_1 > b_2 > ... > b_N
* a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}

Constraints

* 2 \leq N \leq 20,000
* p is a permutation of the set {1, 2, ..., N}

Input

The input is given from Standard Input in the following format:


N
p_1 p_2 ... p_N


Output

The output consists of two lines. The first line contains a_1, a_2, ..., a_N seperated by a space. The second line contains b_1, b_2, ..., b_N seperated by a space.

It can be shown that there always exists a solution for any input satisfying the constraints.

Examples

Input

2
1 2


Output

1 4
5 4


Input

3
3 2 1


Output

1 2 3
5 3 1


Input

3
2 3 1


Output

5 10 100
100 10 1

Source: atcoder | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
n = int(input())
x = list(map(int, input().split()))
a = [20001 * i for i in range(1, n + 1)]
b = [20001 * (n + 1 - i) for i in range(1, n + 1)]
for i in range(n):
	b[x[i] - 1] += i
for x in a:
	print(x, end=' ')
print()
for x in b:
	print(x, end=' ')


n = int(input())
c = list(map(int, input().split()))
a = list(range(n, n ** 2 + 1, n))
b = a[::-1]
for i in range(n):
	b[c[i] - 1] += i
print(*a)
print(*b)


from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
	return int(input())

def reads():
	return [int(x) for x in input().split()]
setrecursionlimit(1000000)
N = read()
p = reads()
q = [0] * N
for i in range(N):
	q[p[i] - 1] = i + 1
a = [0] * N
b = [0] * N
a[0] = 1
b[-1] = 1
for i in range(1, N):
	a[i] = a[i - 1] + q[i]
	b[-1 - i] = b[-i] + q[-1 - i]
print(' '.join((str(x) for x in a)))
print(' '.join((str(x) for x in b)))


n = int(input())
p = list(map(int, input().split()))
p = p[::-1]
a = list(range(1, n * n + 1, n + 1))
b = list(range(n * n + 1, 0, -n - 1))
for i in range(n):
	x = p[i] - 1
	if x == 0:
		b[x] -= i
	else:
		a[x] -= i
print(*a)
print(*b)


def solve(P):
	N = len(P)
	s = N + 1
	A = [s * i + 1 for i in range(N)]
	B = [s * i + 1 for i in reversed(range(N))]
	for (i, p) in enumerate(P):
		A[p - 1] += i
	return (A, B)
N = int(input())
P = list(map(int, input().split()))
(a, b) = solve(P)
print(*a)
print(*b)


n = int(input())
P = list(map(int, input().split()))
Pi = [0] * n
for (i, p) in enumerate(P):
	Pi[p - 1] = i
A = [30000 * (i + 1) for i in range(n)]
B = [30000 * (n - i) + pi for (i, pi) in enumerate(Pi)]
print(' '.join(map(str, A)))
print(' '.join(map(str, B)))


N = int(input())
p = list(map(int, input().split()))
a = [N * (k + 1) for k in range(N)]
b = [N * (N - k) for k in range(N)]
for k in range(N):
	b[p[k] - 1] += k
print(*a, sep=' ')
print(*b, sep=' ')


n = int(input())
p = list(map(int, input().split()))
a = []
b = []
for i in range(n):
	a.append(1 + i * n)
	b.append(n * (n - i - 1) + 1)
for i in range(n):
	a[p[i] - 1] += i
for s in a:
	print(s, end=' ')
print()
for s in b:
	print(s, end=' ')


n = int(input())
p = list(map(int, input().split()))
a = [(i + 1) * n for i in range(n)]
b = [(n - i) * n for i in range(n)]
for i in range(n):
	a[p[i] - 1] -= n - i - 1
sa = ''
sb = ''
for i in range(n):
	sa = sa + str(a[i])
	sb = sb + str(b[i])
	if i != n - 1:
		sa = sa + ' '
		sb = sb + ' '
print(sa)
print(sb)


N = int(input())
P = list(map(int, input().split()))
A = []
B = []
for i in range(N):
	P[i] -= 1
	A.append(40000 * (i + 1))
	B.append(40000 * (N - i))
add = 0
C = []
for p in P:
	if len(C) == 0:
		C.append(A[p] + B[p])
	else:
		c = C[-1]
		if c < A[p] + B[p] + add:
			C.append(A[p] + B[p] + add)
		else:
			add += c - (A[p] + B[p] + add) + 1
			C.append(A[p] + B[p] + add)
	A[p] += add
for a in A:
	print(a + add, end=' ')
print()
for b in B:
	print(b, end=' ')


N = int(input())
P = list(map(int, input().split()))
A = [i * 20000 for i in range(1, N + 1)]
B = [i * 20000 for i in range(N, 0, -1)]
AB = []
for p in P:
	add = A[p - 1] + B[p - 1]
	AB.append([p, add])
for i in range(N - 1):
	if AB[i][1] >= AB[i + 1][1]:
		diff = AB[i][1] - AB[i + 1][1]
		AB[i + 1][1] += diff + 1
		A[AB[i + 1][0] - 1] += diff + 1
A = list(map(str, A))
B = list(map(str, B))
print(' '.join(A))
print(' '.join(B))


N = int(input())
a = list(range(0, N * 20000, 20000))
b = a[::-1]
P = list(map(int, input().split()))
for i in range(N):
	a[P[i] - 1] += i + 1
	b[P[i] - 1] += 1
print(*a)
print(*b)


N = int(input())
P = [int(x) for x in input().split()]
a = [i * N + 1 for i in range(N)]
b = [i * N + 1 for i in reversed(range(N))]
for i in range(N):
	a[P[i] - 1] += i
print(*a)
print(*b)


n = int(input())
arr = list(map(int, input().split()))
ans1 = [40000 * i for i in range(1, n + 1)]
ans2 = [40000 * i for i in range(n, 0, -1)]
for i in range(n):
	ans1[arr[i] - 1] += i
print(*ans1)
print(*ans2)


N = int(input())
p = list(map(int, input().split()))
A = [N * i + 1 for i in range(N)]
B = [N * (N - i - 1) + 1 for i in range(N)]
for i in range(N):
	A[p[i] - 1] += i
print(*A)
print(*B)


(N, *P) = map(int, open(0).read().split())
R = [0] * N
for (i, p) in enumerate(P, 1):
	R[p - 1] = i
A = [30000 * i for i in range(1, N + 1)]
B = [30000 * (N - i) + r for (i, r) in enumerate(R, 1)]
print(*A)
print(*B)


N = int(input())
P = list(map(int, input().split()))
A = [N * i for i in range(1, N + 1)]
B = [N * i for i in reversed(range(1, N + 1))]
for (i, p) in enumerate(P):
	A[p - 1] += i
print(*A)
print(*B)


n = int(input())
l = list(map(int, input().split()))
a = [i * n for i in range(1, n + 1)]
b = [i * n for i in range(1, n + 1)][::-1]
for (i, x) in enumerate(l):
	b[x - 1] += i
print(*a)
print(*b)


def main():
	N = int(input())
	P = list(map(int, input().split()))
	delta = [0] * N
	for (i, p) in enumerate(P):
		delta[p - 1] = i
	A = [0] * N
	B = [0] * N
	A[0] = a = delta[0] + 1
	B[0] = b = int(1000000000.0)
	for i in range(1, N):
		a += 1
		b -= 1
		tmp = delta[i] - delta[i - 1]
		if tmp > 0:
			a += tmp
		else:
			b += tmp
		A[i] = a
		B[i] = b
	print(*A)
	print(*B)
main()


import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	N = int(input())
	P = tuple(map(int, input().split()))
	A = [2 * N * (i + 1) for i in range(N)]
	B = A[::-1]
	cnt = 1
	for (a, b) in zip(P[:-1], P[1:]):
		if a < b:
			A[b - 1] += cnt
		else:
			B[b - 1] += cnt
		cnt += 1
	print(' '.join(map(str, A)))
	print(' '.join(map(str, B)))
main()


N = int(input())
p = list(map(int, input().split()))
a = [(i + 1) * N for i in range(N)]
b = [(N - i) * N for i in range(N)]
for (i, pi) in enumerate(p):
	a[pi - 1] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


N = int(input())
(*P,) = map(int, input().split())
M = 30000
A = [M * i + 1 for i in range(N)]
B = [M * (N - i) for i in range(N)]
for (i, p) in enumerate(P):
	A[p - 1] += i
print(*A)
print(*B)


n = int(input())
p = [int(s) - 1 for s in input().split()]
a = [40000 * (i + 1) for i in range(n)]
b = list(reversed(a))
for i in range(n):
	a[p[i]] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


N = int(input())
p = list(map(int, input().split()))
a = [40000 * i for i in range(1, N + 1)]
b = [40000 * i for i in range(N, 0, -1)]
for i in range(N):
	b[p[i] - 1] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
p = list(map(int, input().split()))
P = [0 for i in range(n)]
for i in range(n):
	P[p[i] - 1] = i + 1
a = []
b = []
for i in range(1, n + 1):
	a.append(str(30000 * i))
	b.append(str(30000 * (n - i) + P[i - 1]))
print(' '.join(a))
print(' '.join(b))


N = int(input())
p = list(map(int, input().split()))
P = []
for j in range(len(p)):
	P.append([p[j], j])
P.sort()
a = []
b = []
for i in range(1, len(p) + 1):
	a.append(str(i * 20001 + P[i - 1][1]))
	b.append(str((len(p) + 1 - i) * 20001 + P[i - 1][1]))
print(' '.join(a))
print(' '.join(b))


N = int(input())
p = list(map(lambda x: int(x) - 1, input().split()))
r = {}
for i in range(N):
	r[p[i]] = i + 1
A = [30000 * i for i in range(1, N + 1)]
B = [30000 * (N - i) + r[i - 1] for i in range(1, N + 1)]
print(*A)
print(*B)


N = int(input())
p = list(map(int, input().split()))
ss = [1] * (N + 1)
ss2 = [-1] * (N + 1)
ss[0] = 0
ss2[0] = 0
for (i, x) in enumerate(p[1:]):
	x -= 1
	ss[x] += i + 1
	ss2[x + 1] -= i + 1
ac = [0] * (N + 1)
ac2 = [0] * (N + 1)
ac[0] = 1
ac2[0] = N ** 2
for i in range(N):
	ac[i + 1] = ac[i] + ss[i]
	ac2[i + 1] = ac2[i] + ss2[i]
print(*ac[1:])
print(*ac2[1:])


N = int(input())
P = [int(_) for _ in input().split()]
a = [1] * N
b = [N] + [-1] * (N - 1)
for (i, x) in enumerate(P):
	a[x - 1] += i
	b[0] += i
	if x < N:
		b[x] -= i
from itertools import accumulate
print(*accumulate(a))
print(*accumulate(b))


def main():
	N = int(input())
	p = list(map(int, input().split()))
	a = dict()
	b = dict()
	for i in range(N):
		v = N * N - N + 2 + i
		a[p[i]] = (p[i] - 1) * N + 1
		b[p[i]] = v - a[p[i]]
	print(' '.join(map(str, [a[i] for i in range(1, N + 1)])))
	print(' '.join(map(str, [b[i] for i in range(1, N + 1)])))
main()


N = int(input())
P = [int(x) for x in input().split()]
R = [1] * N
for (ind, p) in enumerate(P):
	R[p - 1] += ind
A = [30000 * i for i in range(1, N + 1)]
B = [30000 * (N - i - 1) + R[i] for i in range(N)]
print(*A)
print(*B)


N = int(input())
ps = list(map(int, input().split()))
As = [45000 * (i + 1) for i in range(N)]
Bs = list(reversed(As))
for (i, p) in enumerate(ps):
	As[p - 1] += i
	Bs[p - 1] += i
print(*As)
print(*Bs)


def main():
	N = int(input())
	Q = list(map(int, input().split()))
	P = [0] * N
	for i in range(N):
		P[Q[i] - 1] = i + 1
	A = [1]
	B = [1]
	for i in range(N - 1):
		if P[i] < P[i + 1]:
			A.append(A[-1] + P[i + 1] - P[i] + 1)
		else:
			A.append(A[-1] + 1)
	for i in range(N - 2, -1, -1):
		if P[i] > P[i + 1]:
			B.append(B[-1] + P[i] - P[i + 1] + 1)
		else:
			B.append(B[-1] + 1)
	print(' '.join(map(str, A)))
	print(' '.join(map(str, B[::-1])))
main()


n = int(input())
p = reversed(list(map(int, input().split())))
a = [i * 20000 for i in range(1, n + 1)]
b = [i * 20000 for i in range(n, 0, -1)]
for (k, v) in enumerate(p):
	b[v - 1] -= k
print(*a)
print(*b)


n = int(input())
p = list(map(int, input().split()))
a = [(i + 1) * 2 * 10 ** 4 for i in range(n)]
b = [(n - i) * 2 * 10 ** 4 for i in range(n)]
for i in range(n):
	a[p[i] - 1] += i
print(' '.join(list(map(str, a))))
print(' '.join(list(map(str, b))))


n = int(input())
p = list(map(int, input().split()))
a = [i * 20000 for i in range(n)]
b = [(n - i - 1) * 20000 for i in range(n)]
for (i, c) in enumerate(p):
	a[c - 1] += i + 1
	b[c - 1] += i + 1
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
p = list(map(int, input().split()))
a = [30000 * i + 1 for i in range(n)]
b = [30000 * (n - i) for i in range(n)]
for i in range(n):
	b[p[i] - 1] += i
for i in a:
	print(i, end=' ')
print()
for i in b:
	print(i, end=' ')
print()


n = int(input())
p = list(map(int, input().split()))
a = [i * 40000 + 1 for i in range(n)]
b = a[:]
b.reverse()
for i in range(n):
	b[p[i] - 1] += i + 1
print(*a)
print(*b)


n = int(input())
p = list(map(int, input().split()))
print(' '.join(map(str, range(n, n ** 2 + n, n))))
b = list(range(n, n ** 2 + n, n))[::-1]
for (i, x) in enumerate(p):
	b[x - 1] += i
print(' '.join(map(str, b)))


n = int(input())
p = list(map(int, input().split()))
a = [10 ** 8 + i * n for i in range(n)]
b = a[::-1]
for i in range(n):
	a[p[i] - 1] += i
	b[p[i] - 1] += i
print(*a)
print(*b)


import sys
sys.setrecursionlimit(2147483647)
INF = float('inf')
MOD = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip()

def resolve():
	n = int(input())
	M = 20000
	A = [M * i for i in range(1, n + 1)]
	B = [M * (n - i + 1) for i in range(1, n + 1)]
	perm = list(map(lambda x: int(x) - 1, input().split()))
	for i in range(n):
		A[perm[i]] += i
	print(*A)
	print(*B)
resolve()


n = int(input())
indices = list(map(int, input().split()))
a_diff = [1] * n
b_diff = [-1] * n
for (plus, idx) in enumerate(indices):
	idx -= 1
	a_diff[idx] += plus
	b_diff[0] += plus
	if idx + 1 < n:
		b_diff[idx + 1] -= plus
a = []
now = 1
for i in range(n):
	now += a_diff[i]
	a.append(now)
b = []
now = n + 1
for i in range(n):
	now += b_diff[i]
	b.append(now)
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


N = int(input())
p = [(int(a), i + 1) for (i, a) in enumerate(input().split())]
p.sort()
a = [0] * N
b = [0] * N
a[0] = p[0][1]
b[0] = 10 ** 9
for i in range(1, N):
	if p[i][1] > p[i - 1][1]:
		a[i] = a[i - 1] + p[i][1] - p[i - 1][1] + 1
		b[i] = b[i - 1] - 1
	if p[i][1] < p[i - 1][1]:
		a[i] = a[i - 1] + 1
		b[i] = b[i - 1] + p[i][1] - p[i - 1][1] - 1
print(' '.join(list(map(str, a))))
print(' '.join(list(map(str, b))))


N = int(input())
P = [int(i) - 1 for i in input().split()]
a = [0] * N
b = [0] * N
rank = 1
for p in P:
	a[p] = rank
	b[p] = rank
	rank += 1
b.reverse()
for i in range(1, N):
	a[i] += a[i - 1]
	b[i] += b[i - 1]
b.reverse()
print(*a)
print(*b)


class BIT:

	def __init__(self, size):
		self.bit = [0] * (size + 1)
		self.size = size

	def sum(self, i):
		i += 1
		s = 0
		while i > 0:
			s += self.bit[i]
			i -= i & -i
		return s

	def add(self, i, x):
		i += 1
		while i <= self.size:
			self.bit[i] += x
			i += i & -i
N = int(input())
p = list(map(lambda x: int(x) - 1, input().split()))
a = BIT(N)
b = BIT(N)
a.add(0, 1)
b.add(0, N)
for i in range(1, N):
	a.add(i, 1)
	b.add(i, -1)
for (i, j) in enumerate(p):
	a.add(j, i)
	b.add(0, i)
	b.add(j + 1, -i)
print(*[a.sum(i) for i in range(N)])
print(*[b.sum(i) for i in range(N)])


from operator import itemgetter
N = int(input())
P = list(map(int, input().split()))
A = [-1] * N
B = [N * i for i in range(1, N + 1)][::-1]
for (i, p) in enumerate(P):
	p -= 1
	if i == 0:
		A[p] = (p + 1) * N
		AB = A[p] + B[p]
		continue
	A[p] = AB - B[p] + 1
	AB = A[p] + B[p]
print(*A)
print(*B)


n = int(input())
pprr = list(map(int, input().split()))
prr = [0] * n
for (ix, p) in enumerate(pprr):
	prr[p - 1] = ix + 1
arr = []
brr = []
cumsum = 0
for p in prr:
	cumsum += p
	arr.append(cumsum)
cumsum = 0
print(' '.join(map(str, arr)))
for p in reversed(prr):
	cumsum += p
	brr.append(cumsum)
print(' '.join(map(str, reversed(brr))))


from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float('inf')

def main():
	N = int(input())
	p_list = list(map(int, input().split()))
	a_list = [i * N for i in range(1, N + 1)]
	b_list = a_list[::-1]
	for (i, p) in enumerate(p_list):
		a_list[p - 1] += i
	print(*a_list)
	print(*b_list)
main()


n = int(input())
p = list(map(int, input().split()))
a = [30000 * (i + 1) for i in range(n)]
r = [0] * n
f = 1
for i in p:
	r[i - 1] = f
	f += 1
b = [30000 * (n - i - 1) + r[i] for i in range(n)]
print(*a)
print(*b)


n = int(input())
list = input().split()
for i in range(0, n):
	if int(list[i]) == n:
		p = i
		break
list1 = []
list2 = []
for k in range(0, n):
	list1.append(n * int(list[k]) - n + 1)
for k in range(0, n):
	list2.append(max(int(list1[p]) + 1 - p + k - int(list1[k]), n - int(list[k]) + 1))
a = ''
b = ''
list2.sort(reverse=True)
list1.sort()
for l in range(0, n):
	a += str(list1[l])
	a += ' '
	b += str(list2[l])
	b += ' '
print(a)
print(b)


N = int(input())
P = [int(i) for i in input().split()]
asum = [1] * (N + 1)
bsum = [-1] * (N + 1)
bsum[0] = N
for i in range(N):
	p = P[i] - 1
	asum[p + 1] += 20000 - i
	bsum[0] += 20000 - i
	bsum[p] -= 20000 - i
a = [0] * N
b = [0] * N
a[0] = asum[0]
b[0] = bsum[0]
for i in range(1, N):
	a[i] = a[i - 1] + asum[i]
	b[i] = b[i - 1] + bsum[i]
for i in range(N):
	print(a[i], end=' ')
print()
for i in range(N):
	print(b[i], end=' ')


n = int(input())
ps = list(map(int, input().split()))
imos = [None] * n
for (i, p) in enumerate(ps):
	imos[p - 1] = i
a = [0]
b = [0]
for i in range(n):
	a += [a[-1] + 1 + imos[i]]
	b += [b[-1] + 1 + imos[n - i - 1]]
print(*a[1:])
print(*reversed(b[1:]))


n = int(input())
p = [int(_) for _ in input().split()]
a = []
b = []
for i in range(1, n + 1):
	a.append(i * 2 * n)
	b.append((n + 1 - i) * 2 * n)
d = 1
for i in p:
	if d % 2 == 0:
		a[i - 1] += d // 2
		b[i - 1] += d // 2
	else:
		a[i - 1] += d // 2
		b[i - 1] += d // 2
		if a[i - 1] >= b[i - 1]:
			b[i - 1] += 1
		else:
			a[i - 1] += 1
	d += 1
for i in a:
	print(i, end=' ')
print()
for i in b:
	print(i, end=' ')


N = int(input())
P = [int(i) for i in input().split()]
Q = [0] * N
for i in range(N):
	Q[P[i] - 1] = i
L = 30000
A = [L * i for i in range(1, N + 1)]
B = [L * (N + 1 - i) + Q[i - 1] for i in range(1, N + 1)]
print(' '.join(map(str, A)))
print(' '.join(map(str, B)))


n = int(input())
p = list(map(int, input().split()))
a = [20001 * i for i in range(1, n + 1)]
b = [20001 * (n - i + 1) for i in range(1, n + 1)]
num = 0
for e in p:
	e -= 1
	b[e] += num
	num += 1
print(*a)
print(*b)


n = int(input())
p = list(map(int, input().split()))
a = [0] * n
b = [0] * n
c = []
for i in range(n):
	a[i] = 30000 * (i + 1) + 5
	b[i] = 30000 * (n - i - 1) + 5
for i in range(n):
	k = p[i]
	b[k - 1] += i
res = ''
ans = ''
for i in range(n):
	if i == n - 1:
		res += str(a[i])
		ans += str(b[i])
	else:
		res += str(a[i]) + ' '
		ans += str(b[i]) + ' '
print(res)
print(ans)


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	p = list(map(int, input().split()))
	a = [(int(x) + 1) * 20000 for x in range(n)]
	b = [int(x) * 20000 for x in range(n, 0, -1)]
	for i in range(n):
		v = p[i] - 1
		a[v] += i + 1
		b[v] += i + 1
	print(*a)
	print(*b)
main()


def main():
	(n, *p) = map(int, open(0).read().split())
	c = 40000
	a = [c * i for i in range(n)]
	b = [c * (n - i) for i in range(n)]
	for (i, x) in enumerate(p, start=1):
		a[x - 1] += i
	print(*a)
	print(*b)
main()


n = int(input())
p = list(map(int, input().split()))
a = [49999 * (i + 1) for i in range(n)]
b = [49999 * i for i in range(n, 0, -1)]
for i in range(n):
	b[p[i] - 1] += i
print(*a)
print(*b)


def gen_ordinary_lists(n):
	up_lis = list(range(1, n * 20001, 20001))
	return (up_lis, up_lis[::-1])

def argsort(lis):
	tpls = [(l, i) for (i, l) in enumerate(lis)]
	return sorted(tpls)

def solve(N, lis):
	(up_list, down_list) = gen_ordinary_lists(N)
	arg_tpls = argsort(lis)
	for (val, idx) in arg_tpls:
		up_list[val - 1] += idx
	print(*up_list)
	print(*down_list)
N = int(input())
lis = list(map(int, input().split()))
solve(N, lis)


n = int(input())
p = list(map(int, input().split()))
a = [0] * (n + 1)
b = [0] * (n + 1)
for i in range(n):
	if i == 0:
		continue
	a[p[i] - 1] += i
	a[n] -= i
	b[0] += i
	b[p[i]] -= i
for i in range(n):
	a[i + 1] += a[i]
	b[i + 1] += b[i]
for i in range(n):
	ai = i + 1
	bi = n - i
	a[i] += ai
	b[i] += bi
print(*a[:n])
print(*b[:n])


import sys
N = int(sys.stdin.readline())
ps = map(int, sys.stdin.readline().strip().split())
M = N + 5
A = []
B = []
for i in range(N):
	A.append(M * (i + 1))
	B.insert(0, M * (i + 1))
for (i, p) in enumerate(ps):
	B[p - 1] += i
print(' '.join(map(str, A)))
print(' '.join(map(str, B)))


n = int(input())
(*l,) = map(int, input().split())
(*a,) = range(1, 30000 * n + 1, 30000)
b = a[::-1]
for (i, j) in enumerate(l):
	b[j - 1] += i
print(*a)
print(*b)


N = int(input())
src = list(map(int, input().split()))
asc = [N * (n + 1) for n in range(N)]
desc = [N * (n + 1) for n in reversed(range(N))]
for (i, a) in enumerate(src):
	desc[a - 1] += i
print(' '.join(list(map(str, asc))))
print(' '.join(list(map(str, desc))))


n = int(input())
p = [int(i) for i in input().split()]
(a, b) = ([n * i + 1 for i in range(n)], [0 for i in range(n)])
for i in range(n - 1):
	print(a[i], end=' ')
print(a[-1])
for i in range(n):
	b[p[i] - 1] = i - a[p[i] - 1]
x = abs(b[-1]) + 1
for i in range(n - 1):
	print(b[i] + x, end=' ')
print(1)


N = int(input())
p = list(map(int, input().split()))
q = [0 for i in range(N)]
for i in range(N):
	q[p[i] - 1] = i
A = 0
B = 10 ** 9 + 1
ans_a = []
ans_b = []
for i in range(N):
	A += q[i]
	if i != 0:
		B -= q[i - 1]
	A += 1
	B -= 1
	ans_a.append(A)
	ans_b.append(B)
print(*ans_a)
print(*ans_b)


N = int(input())
p = list(map(int, input().split()))
q = [0] * N
for i in range(N):
	q[p[i] - 1] = i
for i in range(N):
	print(30000 * i + 1, end='')
	if i == N - 1:
		print()
	else:
		print(end=' ')
for i in range(N):
	print(30000 * (N - i) + q[i] + 1, end='')
	if i == N - 1:
		print()
	else:
		print(end=' ')


N = int(input())
P = [int(_) - 1 for _ in input().split()]
Q = sorted([(P[i], i) for i in range(N)])
A = [1]
B = [10 ** 9]
for i in range(1, N):
	d = Q[i][1] - Q[i - 1][1]
	if d > 0:
		A += [A[-1] + d + 1]
		B += [B[-1] - 1]
	else:
		A += [A[-1] + 1]
		B += [B[-1] + d - 1]
print(*A, sep=' ')
print(*B, sep=' ')


n = int(input())
lists = list(map(int, input().split()))
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	a[i] = (i + 1) * (4 * 10 ** 4)
	b[i] = (n - i) * (4 * 10 ** 4)
for i in range(n):
	a[lists[i] - 1] += i
	b[lists[i] - 1] += i
print(*a)
print(*b)


import sys
sys.setrecursionlimit(10000000)

def input():
	return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
N = int(input())
P = list(map(int, input().split()))
a = [i * N for i in range(1, N + 1)]
b = a[::-1]
for (i, p) in enumerate(P):
	a[p - 1] += i
print(*a)
print(*b)


N = int(input())
A = [int(i) for i in input().split()]
a = [20000 * i + 1 for i in range(N)]
b = [20000 * (N - i) for i in range(N)]
for i in range(N):
	a[A[i] - 1] += i
a = [str(i) for i in a]
b = [str(i) for i in b]
print(' '.join(a))
print(' '.join(b))


n = int(input())
p = list(map(int, input().split()))
a = [1 + i * n for i in range(n)]
b = [0] * n
for (i, pi) in enumerate(p):
	b[pi - 1] = i - a[pi - 1]
min_b = abs(min(b)) + 1
for i in range(n):
	b[i] += min_b
print(*a)
print(*b)


def main():
	n = int(input())
	p = list(map(int, input().split()))
	c = [0 for i in range(n)]
	for i in range(n):
		c[p[i] - 1] = i + 1
	(a, b) = ([None for i in range(n)], [None for i in range(n)])
	for i in range(n):
		a[i] = str(30000 * (i + 1))
		b[i] = str(30000 * (n - i) + c[i])
	print(' '.join(a))
	print(' '.join(b))
main()


import sys
readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
	n = int(readline())
	p = list(map(int, readline().split()))
	a = [0] * n
	b = [0] * n
	for (i, x) in enumerate(p):
		y = p[i] - 1
		a[y] = (y + 1) * (4 * 10 ** 4) + i
		b[y] = (n - y) * (4 * 10 ** 4)
	print(*a)
	print(*b)
main()


N = int(input())
p = list(map(int, input().split()))
a = [N * i for i in range(1, N + 1)]
b = [N * i for i in range(N, 0, -1)]
for (i, v) in enumerate(p):
	a[v - 1] += i
print(*a)
print(*b)


p = 20000
a = range(p, p * int(input()) + 1, p)
(*b,) = a[::-1]
print(*a)
for (t, i) in enumerate(input().split()):
	b[int(i) - 1] += t
print(*b)


def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	p = getlist()
	a = [N * i for i in range(1, N + 1)]
	b = [N * (N - i) for i in range(N)]
	for i in range(N):
		a[p[i] - 1] += i
	print(' '.join(list(map(str, a))))
	print(' '.join(list(map(str, b))))
main()


a = int(input())
x = list(map(int, input().split()))
t = range(1, a + 1)
A = []
B = []
for i in range(1, a + 1):
	A.append(30000 * i)
	B.append(30000 * (a - i + 1))
for (i, d) in enumerate(x):
	A[d - 1] -= a - i
print(*A)
print(*B)


n = int(input())
p = list(map(int, input().split()))
a = list(range(20000, (n + 1) * 20000, 20000))
b = a[::-1]
for i in range(len(p)):
	a[p[i] - 1] -= n - i - 1
for i in a:
	print(i, end=' ')
print()
for i in b:
	print(i, end=' ')
print()


n = int(input())
p = tuple(map(int, input().split()))
a = [-1] * n
for (x, ind) in enumerate(p, 1):
	a[ind - 1] = x
b = [0] * n
for i in range(1, n):
	b[i] -= a[i - 1]
	a[i] += a[i - 1]
abs_min = abs(min(b)) + 1
b = list(map(lambda x: x + abs_min, b))
print(*a)
print(*b)


N = int(input())
P = list(map(int, input().split()))
for i in range(N):
	P[i] -= 1
A = [30000 * i for i in range(1, N + 1)]
B = list(reversed(A))
ruiA = []
ruiB = []
count = 1
for i in range(0, N)[::-1]:
	B[P[i]] -= count
	count += 1
print(' '.join([str(i) for i in A]))
print(' '.join([str(i) for i in B]))


def main():
	N = int(input())
	P = [int(i) for i in input().split()]
	A = [30000 * (i + 1) for i in range(1, N + 1)]
	B = [30000 * (N - i + 1) for i in range(1, N + 1)]
	for (i, p) in enumerate(P):
		B[p - 1] += i
	print(*A)
	print(*B)
main()


N = int(input())
p = [int(i) for i in input().split()]
A = [0] * N
B = [0] * N
for i in range(1, N):
	if p[i] > p[i - 1]:
		A[p[i] - 1] = A[p[i - 1] - 1] + N * (p[i] - p[i - 1]) + 1
		B[p[i] - 1] = B[p[i - 1] - 1] - N * (p[i] - p[i - 1])
	else:
		A[p[i] - 1] = A[p[i - 1] - 1] + N * (p[i] - p[i - 1])
		B[p[i] - 1] = B[p[i - 1] - 1] - N * (p[i] - p[i - 1]) + 1
(ma, mb) = (min(A), min(B))
for i in range(N):
	A[i] = A[i] - ma + 1
	B[i] = B[i] - mb + 1
print(*A)
print(*B)


N = int(input())
P = [int(x) for x in input().split()]
A = []
B = []
for i in range(N):
	A.append((i + 1) * N)
	B.append((N - i) * N)
for i in range(N):
	A[P[i] - 1] += i
print(*A)
print(*B)


n = int(input())
p = [int(m) for m in input().split()]
a = [i * n + (i - 1) for i in range(1, n + 1)]
b = [i * n + (i - 1) for i in range(n, 0, -1)]
for i in range(n):
	a[p[i] - 1] += i + 1
for i in range(n):
	print(a[i], '', end='')
print()
for i in range(n):
	print(b[i], '', end='')


N = int(input())
P = [int(p) for p in input().split()]
A = [30000 * i for i in range(1, N + 1)]
R = [0 for i in range(N)]
for i in range(N):
	R[P[i] - 1] = i + 1
B = [30000 * (N - i) + R[i - 1] for i in range(1, N + 1)]
print(' '.join(map(str, A)))
print(' '.join(map(str, B)))


N = int(input())
p = list(map(int, input().split()))
(M, S) = (10 ** 9, 30000)
a = list(range(1, S * N, S))
b = list(reversed(a))
for i in range(N - 1):
	b[p[i + 1] - 1] += i + 1
print(*a)
print(*b)


N = int(input())
P = list(map(int, input().split()))
A = [1 for _ in range(N + 1)]
B = [0 for _ in range(N + 1)]
L = [0 for _ in range(N + 1)]
for i in range(N):
	L[P[i]] = 2 * i
B[1] = L[1] - A[1]
for i in range(2, N + 1):
	if L[i] > L[i - 1]:
		B[i] = B[i - 1] - 1
		A[i] = L[i] - B[i]
	else:
		A[i] = A[i - 1] + 1
		B[i] = L[i] - A[i]
b = abs(B[-1]) + 1
for i in range(1, N + 1):
	B[i] += b
print(*A[1:])
print(*B[1:])


n = int(input())
ps = [int(p) for p in input().split()]
ls = [0 for _ in range(n)]
for (i, p) in enumerate(ps):
	ls[p - 1] = i
cs = [ls[0]]
for i in range(1, n):
	cs.append(cs[-1] + ls[i])
xs = [c + 1 + i for (i, c) in enumerate(cs)]
ys = [cs[-1] + n + 1] + [cs[-1] - c + 1 + n - i for (i, c) in zip(range(1, n), cs)]
print(' '.join(map(str, xs)))
print(' '.join(map(str, ys)))


import sys
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def II():
	return int(sys.stdin.readline())

def SI():
	return input()
from itertools import accumulate

def main():
	N = II()
	P = LI()
	T = [1] * N
	for (i, p) in enumerate(P):
		T[p - 1] += i
	A = list(accumulate(T))
	B = list(accumulate(T[::-1]))[::-1]
	print(*A)
	print(*B)
	return 0
main()


n = int(input())
p = list(map(int, input().split()))
a = []
b = []
x = [0] * n
for i in range(n):
	x[p[i] - 1] = 800000000 + i
a.append(1)
b.append(x[0] - 1)
for i in range(1, n):
	y = a[-1] + 1
	z = b[-1] - 1
	if y + z > x[i]:
		z = x[i] - y
	if y + z < x[i]:
		y = x[i] - z
	a.append(y)
	b.append(z)
print(*a)
print(*b)


n = int(input())
P = [int(x) for x in input().split()]
b = [None] * (n + 1)
b[P[0]] = 1
bs = {1}
for (p, pprev) in zip(P[1:], P):
	bp = b[pprev] + (pprev - p) * 20000 + 1
	while bp in bs:
		bp += 1
	b[p] = bp
	bs.add(bp)
offset = 1 - min(b[1:])
b = [i + offset for i in b[1:]]
print(' '.join([str(20000 * i) for i in range(1, n + 1)]))
print(' '.join([str(i) for i in b]))


n = int(input())
p = 20000
a = range(p, p * n + 1, p)
(*b,) = a[::-1]
print(*a)
for (t, i) in zip(range(n), input().split()):
	b[int(i) - 1] += t
print(*b)


N = int(input())
P = [int(x) - 1 for x in input().split()]
A = [0] * N
B = [0] * N
D = [0] * N
for (i, p) in enumerate(P):
	D[p] = i
for i in range(P[0] + 1, N):
	if D[i] > D[i - 1]:
		B[i] = B[i - 1] - 1
		A[i] = D[i] - B[i]
	else:
		A[i] = A[i - 1] + 1
		B[i] = D[i] - A[i]
for i in range(P[0] - 1, -1, -1):
	if D[i] > D[i + 1]:
		A[i] = A[i + 1] - 1
		B[i] = D[i] - A[i]
	else:
		B[i] = B[i + 1] + 1
		A[i] = D[i] - B[i]
_a = 1 - A[0]
_b = 1 - B[-1]
print(' '.join([str(a + _a) for a in A]))
print(' '.join([str(b + _b) for b in B]))


n = int(input())
p = [int(item) for item in input().split()]
a = []
for i in range(n):
	a.append(20001 * (i + 1))
b = list(reversed(a))
for (i, item) in enumerate(p):
	a[item - 1] -= n - i
	b[item - 1] -= n - i
print(' '.join([str(item) for item in a]))
print(' '.join([str(item) for item in b]))


N = int(input())
p_list = list(map(int, input().split()))
r = {}
for i in range(N):
	r[p_list[i]] = i + 1
a_list = []
b_list = []
for i in range(1, N + 1):
	a_list.append(30000 * i)
	b_list.append(30000 * (N - i) + r[i])
print(*a_list)
print(*b_list)


n = int(input())
p = list(map(int, input().split()))
a = [3 * (i + 1) * pow(10, 4) for i in range(n)]
b = list(a)
b.reverse()
p.reverse()
for i in range(n):
	a[p[i] - 1] -= i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
x = list(map(int, input().split()))
a = list(range(1, n * 30000 + 1, 30000))
b = list(range(n * 30000, 0, -30000))
for (i, j) in enumerate(x):
	b[j - 1] += i
print(*a)
print(*b)


N = int(input())
p = list(map(int, input().split()))
a = [30000 * (i + 1) for i in range(N)]
b = [30000 * (N - i) for i in range(N)]
for i in range(0, N):
	a[p[i] - 1] += i
	b[p[i] - 1] += i
print(*a)
print(*b)


n = int(input())
p = list(map(int, input().split()))
l = [0] * n
for i in range(n):
	l[p[i] - 1] = i
a = [3 * 10 ** 4 * (i + 1) for i in range(n)]
b = [3 * 10 ** 4 * (n - i) + l[i] for i in range(n)]
print(*a)
print(*b)


N = int(input())
P = [int(p) for p in input().split()]
A = [i * (N + 1) for i in range(1, N + 1)]
B = [0] * N
B[P[0] - 1] = 1
for i in range(1, N):
	B[P[i] - 1] = A[P[i - 1] - 1] + B[P[i - 1] - 1] - A[P[i] - 1] + 1
num = min(B)
if num <= 0:
	num = -num + 1
	for i in range(N):
		B[i] += num
for i in range(N):
	A[i] = str(A[i])
	B[i] = str(B[i])
print(' '.join(A))
print(' '.join(B))


n = int(input())
p = list(map(int, input().split()))
p_index = sorted([[p[i], i] for i in range(n)], key=lambda x: x[0])
q = [p_index[i][1] for i in range(n)]
a = [n * (i + 1) for i in range(n)]
b = list(reversed(a))
a = [a[i] + q[i] - 1 for i in range(n)]
print(' '.join(list(map(str, a))))
print(' '.join(list(map(str, b))))


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
P = [int(x) for x in input().split()]
L = 2 * N + 100
A = [None] + [L * i for i in range(1, N + 1)]
B = [None] + [L * (N + 1 - i) for i in range(1, N + 1)]
for (i, p) in enumerate(P, 1):
	A[p] += i
print(' '.join(map(str, A[1:])))
print(' '.join(map(str, B[1:])))


N = int(input())
p = list(map(int, input().split()))
A = [0 for _ in range(N)]
B = [0 for _ in range(N)]
X = [0 for _ in range(N)]
S = N
A[0] = 1
for i in range(N - 1):
	S += abs(p[i] - p[i - 1])
for i in range(N):
	X[p[i] - 1] = S + i
B[0] = X[0] - 1
for i in range(1, N):
	s = max(A[i - 1] + 1, X[i] - B[i - 1] + 1)
	A[i] = s
	B[i] = X[i] - s
if min(min(A), min(B)) <= 0:
	m = -min(min(A), min(B)) + 1
	for i in range(N):
		A[i] += m
		B[i] += m
for i in range(N):
	if i != N - 1:
		print(A[i], end=' ')
	else:
		print(A[i])
for i in range(N):
	if i != N - 1:
		print(B[i], end=' ')
	else:
		print(B[i])


import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop, heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10 ** 9 + 7
inf = float('inf')

def I():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))
n = I()
p = LI()
a = [i * n for i in range(1, n + 1)]
b = a[::-1]
for i in range(n):
	a[p[i] - 1] += i
print(*a)
print(*b)


from itertools import accumulate
N = int(input())
ps = list(map(int, input().split()))
ds = [0] * N
for (i, p) in enumerate(ps):
	ds[p - 1] = N - i
As = accumulate([1] + ds[:-1])
Bs = reversed(list(accumulate([1] + ds[1:][::-1])))
print(' '.join(map(str, As)))
print(' '.join(map(str, Bs)))


import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
N = int(input())
P = list(map(int, input().split()))
A = [N * i + 1 for i in range(1, N + 1)]
B = list(reversed(A))
for (i, p) in enumerate(P):
	A[p - 1] -= N - i
print(*A)
print(*B)


import sys
stdin = sys.stdin
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))
nn = lambda : list(stdin.readline().split())
ns = lambda : stdin.readline().rstrip()
n = ni()
p = na()
a = [20000 * i for i in range(1, n + 1)]
b = list(reversed(a))
j = 1
for i in p:
	b[i - 1] += j
	j += 1
print(' '.join([str(m) for m in a]))
print(' '.join([str(m) for m in b]))


n = int(input())
a = list(map(int, input().split()))
lis = [40000 * i + 1 for i in range(n)]
li = [str(40000 * (n - i) + 1) for i in range(n)]
for i in range(n):
	lis[a[i] - 1] += i
	lis[a[i] - 1] = str(lis[a[i] - 1])
print(' '.join(lis))
print(' '.join(li))


n = int(input())
p = list(map(int, input().split()))
d = {x - 1: i + 1 for (i, x) in enumerate(p)}
a = [30000 * i for i in range(1, n + 1)]
b = [30000 * (n - i) + d[i] for i in range(n)]
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	n = int(input())
	P = list(map(int, input().split()))
	MAX = 10 ** 9 - n
	A = list(range(1, MAX + 2, MAX // (n - 1)))
	T = list(range(1, n + 1))
	B = [0] * n
	for i in range(n):
		idx = P[i] - 1
		B[idx] = T[i] - A[idx]
	mi = min(B)
	if mi <= 0:
		d = mi * -1 + 1
		B = [b + d for b in B]
	print(*A)
	print(*B)
resolve()


import sys
input = sys.stdin.readline
N = int(input())
p = list(map(int, input().split()))
res = [0] * N
for i in range(N):
	res[p[i] - 1] = 10 ** 9 - N + i + 1
a = [1]
b = [res[0] - 1]
for i in range(1, N):
	if res[i] - a[-1] - 1 >= b[-1]:
		b.append(b[-1] - 1)
		a.append(res[i] - b[-1])
	else:
		a.append(a[-1] + 1)
		b.append(res[i] - a[-1])
print(*a)
print(*b)


n = int(input())
p = list(map(int, input().split()))
a = [20001 * i + 1 for i in range(n)]
b = [20001 * i + 1 for i in range(n)][::-1]
for i in range(n):
	a[p[i] - 1] += i
print(*a)
print(*b)


N = int(input())
p = list(map(int, input().split()))
a = [0] * N
b = [0] * N
for i in range(N):
	a[p[i] - 1] = p[i] * 22000 + 500000000
	b[p[i] - 1] = -p[i] * 22000 + i + 500000000
print(*a)
print(*b)


def main():
	n = int(input())
	p = list(map(int, input().split()))
	a = [0] * n
	b = [0] * n
	for (i, v) in enumerate(p):
		(x, y) = (i + 1, v - 1)
		a[y] += x
		b[y] += x
	for i in range(n - 1):
		a[i + 1] += a[i]
	for i in reversed(range(1, n)):
		b[i - 1] += b[i]
	for v in a:
		print(v, end=' ')
	print()
	for v in b:
		print(v, end=' ')
main()


n = int(input())
l = list(map(int, input().split()))
a = [(n + 1) * (i + 1) for i in range(n)]
b = a[::-1]
for i in range(n):
	a[l[i] - 1] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


N = int(input())
P = list(map(int, input().split()))
A = [1 for i in range(N)]
B = [1 for i in range(N)]
for i in range(N):
	A[P[i] - 1] += i
	B[P[i] - 1] += i
for i in range(N - 1):
	A[i + 1] += A[i]
	B[N - i - 2] += B[N - i - 1]
print(*A)
print(*B)


import sys
import heapq
import bisect
mod = 10 ** 9 + 7
dd = ((-1, 0), (1, 0), (0, -1), (0, 1))

def I():
	return int(sys.stdin.readline())

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def S():
	return sys.stdin.readline()[:-1]

def IR(n):
	return [I() for _ in range(n)]

def GCD(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a

def LCM(a, b):
	return a * b // GCD(a, b)

def main():
	N = I()
	P = LI()
	a = [45000 * i + 1 for i in range(N)]
	b = [45000 * (N - 1 - i) + 1 for i in range(N)]
	for i in range(N):
		a[P[i] - 1] += i
		b[P[i] - 1] += i
	print(' '.join(map(str, a)))
	print(' '.join(map(str, b)))
main()


n = int(input())
l = [int(i) for i in input().split()]
b = []
for i in range(n):
	b.append(22000 * i + 1)
a = b[:]
b.reverse()
for i in range(1, n):
	a[l[i] - 1] += i
print(*a)
print(*b)


n = int(input())
plist = list(map(int, input().split()))
pd = {}
for (i, p) in enumerate(plist):
	pd[p] = i + 1
al = [30000 * i for i in range(1, n + 1)]
print(*al)
bl = [30000 * (n - i) + pd[i] for i in range(1, n + 1)]
print(*bl)


from itertools import *
from math import *
from collections import *
from heapq import *
from bisect import bisect_left, bisect_right
from copy import deepcopy
inf = float('inf')
mod = 10 ** 9 + 7
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)
N = int(input())
p = list(map(int, input().split()))
d = defaultdict(int)
for i in range(N):
	d[p[i]] = i
(a, b) = ([], [])
for i in range(1, N + 1):
	a.append(N * i + d[i])
	b.append((N - i + 1) * N + d[i])
print(*a, sep=' ')
print(*b, sep=' ')


n = int(input())
p = [int(i) for i in input().split()]
a = [30000 * i for i in range(n)]
b = [30000 * (n - i) for i in range(n)]
for (i, v) in enumerate(p):
	a[v - 1] += i + 1
print(*a)
print(*b)


N = int(input())
P = [int(x) for x in input().split()]
a = [(i + 1) * 2 * 10 ** 4 for i in range(N)]
b = list(reversed(a))
for i in range(N):
	p = P[i] - 1
	a[p] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))

def check():
	tmp = 0
	for i in P:
		i -= 1
		if not tmp < a[i] + b[i]:
			raise
		tmp = a[i] + b[i]
	return True


n = int(input())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
A = list(range(1, n + 1))
B = list(reversed(range(1, n + 1)))
C = [0] * (n + 1)
D = [0] * (n + 1)
for i in range(n):
	p = P[i]
	C[p] += i + 1
	C[n] -= i + 1
	D[0] += i + 1
	D[p + 1] -= i + 1
from itertools import accumulate
C = list(accumulate(C))
D = list(accumulate(D))
A_ = [0] * n
B_ = [0] * n
for i in range(n):
	A_[i] = A[i] + C[i]
	B_[i] = B[i] + D[i]
print(*A_)
print(*B_)


N = int(input())
p_arr = list(map(int, input().split()))
for i in range(N):
	p_arr[i] -= 1
a_arr = [N * i + 1 for i in range(N)]
b_arr = [0] * N
for i in range(N):
	b_arr[p_arr[i]] = N * (N - p_arr[i]) + i + 1
a_output = ''
b_output = ''
for i in range(N):
	a_output += str(a_arr[i])
	b_output += str(b_arr[i])
	if i == N - 1:
		continue
	else:
		a_output += ' '
		b_output += ' '
print(a_output)
print(b_output)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 10
mod = 10 ** 9 + 7

def f():
	n = int(input())
	a = list(map(int, input().split()))
	ra = []
	for i in range(n):
		ra.append((i + 1) * 30000)
	rb = []
	c = 1
	for i in range(n):
		rb.append((n - i) * 30000)
	for i in a:
		rb[i - 1] += c
		c += 1
	print(' '.join(map(str, ra)))
	print(' '.join(map(str, rb)))
f()


import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def li():
	return map(int, stdin.readline().split())

def li_():
	return map(lambda x: int(x) - 1, stdin.readline().split())

def lf():
	return map(float, stdin.readline().split())

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(stdin.readline())

def nf():
	return float(stdin.readline())
n = ni()
p = list(li_())
a = [i * n for i in range(1, n + 1)]
b = [i * n for i in range(1, n + 1)][::-1]
for (i, pi) in enumerate(p):
	a[pi] += i
	b[pi] += i
print(*a)
print(*b)


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10 ** 9))
n = int(input())
ps = [item - 1 for item in map(int, input().split())]
aind = [0] * n
bind = [0] * n
for (i, p) in enumerate(ps):
	aind[p] = i
	bind[p] = i
for i in range(1, n):
	aind[i] += aind[i - 1]
	bind[-i - 1] += bind[-i]
for i in range(n):
	aind[i] += i + 1
	bind[i] += n - i
print(' '.join(map(str, aind)))
print(' '.join(map(str, bind)))


n = int(input())
p = list(map(int, input().split()))
x = [10 ** 9] * n
for i in range(n):
	x[p[i] - 1] -= n - i - 1
a = [1]
b = [x[0] - a[0]]
for i in range(n - 1):
	t = max(a[-1], 10 ** 9 - b[-1])
	a.append(t + 1)
	b.append(x[i + 1] - t - 1)
print(*a)
print(*b)


N = int(input())
P = list(map(int, input().split()))
(A, B) = ([0] * N, [0] * N)
for i in range(N):
	A[i] = 20001 * (i + 2)
	B[i] = 20001 * (N - i)
for i in range(N):
	a = P[i] - 1
	A[a] += i
print(*A)
print(*B)


import sys
stdin = sys.stdin

def li():
	return [int(x) for x in stdin.readline().split()]

def li_():
	return [int(x) - 1 for x in stdin.readline().split()]

def lf():
	return [float(x) for x in stdin.readline().split()]

def ls():
	return stdin.readline().split()

def ns():
	return stdin.readline().rstrip()

def lc():
	return list(ns())

def ni():
	return int(ns())

def nf():
	return float(ns())
n = ni()
p = li_()
a = [i * n + 1 for i in range(n)]
b = a[::-1]
ad = 0
for pi in p:
	a[pi] += ad
	b[pi] += ad
	ad += 1
print(*a)
print(*b)


(N, *P) = map(int, open(0).read().split())
b = list(range(N * N, N - 1, -N))
a = [0] * N
for (i, p) in enumerate(P):
	a[p - 1] = N * p + i
print(*a)
print(*b)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
n = int(input())
P = list(map(int, input().split()))
(A, B) = ([], [])
for i in range(1, n + 1):
	A.append(25000 * i)
	B.append(25000 * (n - i + 1))
for (i, p) in enumerate(P):
	A[p - 1] += i
print(*A)
print(*B)


N = int(input())
P = list(map(int, input().split()))
(A, B) = ([], [])
R = 2 * 10 ** 4 + 1
for i in range(N):
	A.append(1 + R * i)
	B.append(10 ** 9 - R * i)
for (i, p) in enumerate(P):
	p -= 1
	A[p] += i
print(*A)
print(*B)


n = int(input())
a = list(map(int, input().split()))
b = [None for _ in range(n)]
for (i, j) in enumerate(a):
	b[j - 1] = i
print(*[20001 * i + b[i] + 1 for i in range(n)])
print(*[20001 * (n - i) for i in range(n)])


N = int(input())
P = list(map(int, input().split()))
M = 40000
A = []
B = []
for i in range(N):
	A.append(M * i)
	B.append(M * (N - i))
for i in range(N):
	A[P[i] - 1] += i + 1
print(*A)
print(*B)


n = int(input())
p = list(map(int, input().split()))
p = [(x - 1, i + 1) for (i, x) in enumerate(p)]
p.sort()
a = [0] * n
b = [0] * n
for (i, j) in p:
	a[i] = (n + 1) * i + 1
	b[i] = (n + 1) * (n - i) + j
f = lambda x: ' '.join(list(map(lambda n: str(n), x)))
print(f(a))
print(f(b))


n = int(input())
P = list(map(int, input().split()))
M = 3 * 10 ** 4
A = [M * i for i in range(1, n + 1)]
B = A[::-1]
for (i, p) in enumerate(P):
	B[p - 1] += i
print(*A)
print(*B)


N = input()
l = input().split()
N = int(N)
a = range(1, N + 1)
b = range(1, N + 1)
a = [i * N for i in a]
b = [i * N for i in b]
b.reverse()
c = 0
for i in l:
	i = int(i)
	b[i - 1] += c
	c += 1
for i in a:
	print(i, end=' ')
print('')
for i in b:
	print(i, end=' ')


n = int(input())
p = list(map(int, input().split()))
a = [1 + 30000 * i for i in range(n)]
b = [1 + 30000 * i for i in range(n - 1, -1, -1)]
t = 0
for x in p:
	a[x - 1] += t
	t += 1
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
p = list(map(int, input().split()))
a = [1]
for num in range(1, n):
	a.append(num * 22000)
c = [0] * n
p = list(reversed(p))
new_p = [0] * n
for i in range(n):
	new_p[p[i] - 1] = i
for i in range(n):
	c[i] = 10 ** 9 - new_p[i]
b = [0] * n
for i in range(n):
	b[i] = c[i] - a[i]
print(*a)
print(*b)


n = int(input())
p = [i for (i, j) in sorted([[i, pp] for (i, pp) in enumerate(map(int, input().split()))], key=lambda t: t[1])]
a = []
acc = 0
for i in range(n):
	acc += p[i]
	a.append(i + 1 + acc)
b = []
acc = 0
for i in range(n):
	acc += p[-i - 1]
	b.append(i + 1 + acc)
print(*a)
print(*b[::-1])


N = int(input())
(*P,) = map(int, input().split())
d = 21000
A = [i * d for i in range(N)]
B = A[::-1]
for (i, p) in enumerate(P, 1):
	A[p - 1] += i
	B[p - 1] += i
print(*A)
print(*B)


N = int(input())
p = list(map(int, input().split()))
A = [0] * N
B = [N * (N + 1) // 2] * N
for i in range(N):
	A[p[i] - 1] += i + 1
cnt = A[0]
A[0] = 1
for i in range(1, N):
	B[i] -= cnt
	cnt += A[i]
	A[i] += A[i - 1]
print(' '.join(list(map(str, A))))
print(' '.join(list(map(str, B))))


import sys
input = sys.stdin.buffer.readline

def main():
	N = int(input())
	p = list(map(int, input().split()))
	a = [N * i + 1 for i in range(N)]
	b = [N * (N - i - 1) + 1 for i in range(N)]
	for (i, num) in enumerate(p):
		a[num - 1] += i
	print(*a)
	print(*b)
main()


from random import shuffle
from collections import Counter

def inpl():
	return list(map(int, input().split()))
N = int(input())
P = inpl()
A = [0] * N
B = [0] * N
S = [10 ** 9 - N] * N
for (i, p) in enumerate(P):
	S[p - 1] += i
A[0] = 1
B[0] = S[0] - 1
for i in range(1, N):
	A[i] = max(A[i - 1] + 1, S[i] - B[i - 1] + 1)
	B[i] = S[i] - A[i]
for i in range(N - 1):
	assert A[i] < A[i + 1]
	assert B[i] > B[i + 1]
assert B[-1] > 0
print(*A)
print(*B)


n = int(input())
a = [25252 * (i + 1) for i in range(n)]
b = [25252 * (n - i) for i in range(n)]
l = list(map(int, input().split()))
for i in range(n):
	b[l[i] - 1] += i + 1
print(*a)
print(*b)


N = int(input())
P = list(map(int, input().split()))
L = 2 * N
for i in range(1, N + 1):
	print(i * L, end=' ')
print()
B = [L * (N - i) for i in range(1, N + 1)]
for (i, p) in enumerate(P):
	B[p - 1] += i + 1
print(' '.join([str(a) for a in B]))


import sys
input = sys.stdin.readline
n = int(input())
p = list(map(int, input().split()))
ps = []
for i in range(n):
	ps.append((p[i], i))
ps.sort()
s = 1
for i in range(n):
	print(s + ps[i][1], end='')
	print(' ', end='')
	s = s + 30000
print('')
s = 1 + 30000 * (n - 1)
for i in range(n):
	print(s, end='')
	print(' ', end='')
	s = s - 30000


n = int(input())
P = list(map(int, input().split()))
A = [30000 * (i + 1) for i in range(n)]
B = A[::-1]
for (i, j) in enumerate(P):
	A[j - 1] += i
print(*A)
print(*B)


a = range(1, 8 ** 5 * int(input()) + 1, 8 ** 5)
(*b,) = a[::-1]
print(*a)
for (t, i) in enumerate(input().split()):
	b[int(i) - 1] += t
print(*b)


from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
ins = lambda : input().strip()
DBG = True
BIG = 999999999
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
n = inn()
p = inl()
c = 20001
a = [c * i for i in range(1, n + 1)]
b = [c * (n + 1 - i) for i in range(1, n + 1)]
for i in range(n):
	a[p[i] - 1] += i
pad = ''
for i in range(n):
	printn(pad + str(a[i]))
	pad = ' '
print('')
pad = ''
for i in range(n):
	printn(pad + str(b[i]))
	pad = ' '
print('')


n = int(input())
p = list(map(int, input().split()))
a = [n * (i + 1) for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	j = p[i] - 1
	b[j] = n * (n + 1) - a[j] + i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
line = input().split()
for i in range(n):
	line[i] = int(line[i])
b = []
for i in range(n):
	b.append(22000 * i + 1)
a = b[:]
b.reverse()
for i in range(1, n):
	a[line[i] - 1] += i
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


n = int(input())
p = [int(i) for i in input().split()]
a = [i * 20000 for i in range(1, n + 1)]
b = [(n - i + 1) * 20000 for i in range(1, n + 1)]
c = [0 for i in range(n)]
for i in range(n):
	c[i] = a[i] + b[i]
for i in range(n - 1):
	if p[i] > p[i + 1]:
		b[p[i + 1] - 1] += c[p[i] - 1] - c[p[i + 1] - 1] + 1
		c[p[i + 1] - 1] += c[p[i] - 1] - c[p[i + 1] - 1] + 1
	else:
		a[p[i + 1] - 1] += c[p[i] - 1] - c[p[i + 1] - 1] + 1
		c[p[i + 1] - 1] += c[p[i] - 1] - c[p[i + 1] - 1] + 1
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))


N = int(input())
P = list(map(int, input().split()))
A = [i * (10 ** 4 * 2 + 1) + 1 for i in range(N)]
B = list(reversed(A))
for i in range(N):
	B[P[i] - 1] += i
for i in A:
	print(i, end=' ')
print()
for i in B:
	print(i, end=' ')


f = lambda : map(int, input().split())
n = int(input())
p = list(f())
m = 3 * 10 ** 4
k = 10 ** 9
a = [i * m for i in range(1, n + 1)]
b = [k - a[i] for i in range(n)]
for i in range(n):
	b[p[i] - 1] += i
print(*a)
print(*b)


n = int(input())
a = [int(i) for i in input().split()]
ans1 = [(i + 1) * n for i in range(n)]
ans2 = [(i + 1) * n for i in range(n - 1, -1, -1)]
for i in range(n):
	ans2[a[i] - 1] += i
print(*ans1)
print(*ans2)


n = int(input())
p = [int(x) - 1 for x in input().split()]
x = 5 * 10 ** 4
a = [1 + i * x for i in range(n)]
b = a[::-1]
for i in range(1, n):
	a[p[i]] += i
print(*a)
print(*b)


N = int(input())
Ps = list(map(int, input().split()))

def solve(Ps):
	n = len(Ps)
	As = [x * 30000 + 1 for x in range(n)]
	Bs = list(reversed(As[:]))
	for (i, p) in enumerate(Ps):
		Bs[p - 1] += i
	return (As, Bs)
(As, Bs) = solve(Ps)
print(*As)
print(*Bs)


N = int(input())
P = list(map(int, input().split()))
A = [i * N for i in range(1, N + 1)]
B = [-1] * N
p = P[0]
B[p - 1] = N * (N - p + 1)
for (x, y) in zip(P[:-1], P[1:]):
	x -= 1
	y -= 1
	Xsum = A[x] + B[x]
	Ysum = Xsum + 1
	B[y] = Ysum - A[y]
print(*A)
print(*B)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
B = [[0] * n for i in range(2)]
k = 10 ** 4 * 3
for i in range(n):
	B[0][i] = k * (i + 1)
	B[1][n - 1 - i] = k * (i + 1)
for i in range(n):
	B[0][A[i] - 1] += i
for i in range(2):
	print(' '.join([str(j) for j in B[i]]))


import sys
import heapq
from operator import itemgetter
from collections import deque, defaultdict
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def sol():
	N = int(input())
	P = list(map(int, input().split()))
	index = [-1] * (N + 1)
	for (i, p) in enumerate(P):
		index[p] = i + 1
	offset = 30000
	A = [0] * N
	B = [0] * N
	for (i, p) in enumerate(P):
		A[i] = index[i + 1] + offset * (i + 1)
		B[i] = offset * N - offset * i
	print(*A)
	print(*B)
sol()


N = int(input())
p = list(map(int, input().split()))
a = [0] * N
b = [0] * N
for i in range(N):
	c = 49999
	a[p[i] - 1] = c * p[i]
	b[p[i] - 1] = i + 1 - c * p[i]
m = min(b)
b = map(lambda x: x - m + 1, b)
print(' '.join(map(str, a)))
print(' '.join(map(str, b)))