#AGC007B. [AGC007B] Construct Sequences

[AGC007B] Construct Sequences

Score : 400400 points

Problem Statement

You are given a permutation pp of the set {1,2,...,N1, 2, ..., N}. Please construct two sequences of positive integers a1a_1, a2a_2, ..., aNa_N and b1b_1, b2b_2, ..., bNb_N satisfying the following conditions:

  • 1ai,bi1091 \leq a_i, b_i \leq 10^9 for all ii
  • a1<a2<...<aNa_1 < a_2 < ... < a_N
  • b1>b2>...>bNb_1 > b_2 > ... > b_N
  • $a_{p_1}+b_{p_1} < a_{p_2}+b_{p_2} < ... < a_{p_N}+b_{p_N}$

Constraints

  • 2N20,0002 \leq N \leq 20,000
  • pp is a permutation of the set {1,2,...,N1, 2, ..., N}

Input

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

NN

p1p_1 p2p_2 ...... pNp_N

Output

The output consists of two lines. The first line contains a1a_1, a2a_2, ..., aNa_N seperated by a space. The second line contains b1b_1, b2b_2, ..., bNb_N seperated by a space.

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

2
1 2
1 4
5 4

a1+b1=6a_1 + b_1 = 6 and a2+b2=8a_2 + b_2 = 8. So this output satisfies all conditions.

3
3 2 1
1 2 3
5 3 1
3
2 3 1
5 10 100
100 10 1