Score : 300 points
Problem Statement
You are given strictly increasing sequences of length N and M: A=(A1,A2,…,AN) and B=(B1,B2,…,BM).
Here, Ai=Bj for every i and j (1≤i≤N,1≤j≤M).
Let C=(C1,C2,…,CN+M) be a strictly increasing sequence of length N+M that results from the following procedure.
- Let C be the concatenation of A and B. Formally, let Ci=Ai for i=1,2,…,N, and Ci=Bi−N for i=N+1,N+2,…,N+M.
- Sort C in ascending order.
For each of A1,A2,…,AN,B1,B2,…,BM, find its position in C.
More formally, for each i=1,2,…,N, find k such that Ck=Ai, and for each j=1,2,…,M, find k such that Ck=Bj.
Constraints
- 1≤N,M≤105
- 1≤A1<A2<⋯<AN≤109
- 1≤B1<B2<⋯<BM≤109
- Ai=Bj for every i and j (1≤i≤N,1≤j≤M).
- All values in the input are integers.
The input is given from Standard Input in the following format:
N M
A1 A2 … AN
B1 B2 … BM
Output
Print the answer in two lines.
The first line should contain the positions of A1,A2,…,AN in C, with spaces in between.
The second line should contain the positions of B1,B2,…,BM in C, with spaces in between.
4 3
3 14 15 92
6 53 58
1 3 4 7
2 5 6
C will be (3,6,14,15,53,58,92).
Here, the 1-st, 3-rd, 4-th, 7-th elements are from A=(3,14,15,92), and the 2-nd, 5-th, 6-th elements are from B=(6,53,58).
4 4
1 2 3 4
100 200 300 400
1 2 3 4
5 6 7 8
8 12
3 4 10 15 17 18 22 30
5 7 11 13 14 16 19 21 23 24 27 28
1 2 5 9 11 12 15 20
3 4 6 7 8 10 13 14 16 17 18 19