Plus
Pin


Problem description Progress
ID 45458. Merge sort
Темы: Merge sort   

Sort this array using merge sort.


Input
The first line of the input contains the number of elements in the array NN <= 105. Next comes N integers not exceeding 109 in absolute value.


Imprint
Print these numbers in non-decreasing order.
 
Examples
# Input Output
1 2
3 1
1 3

ID 45459. Two arrays (lite)
Темы: Merge sort   

Alice and her father Professor Seleznev write down the numbers of a certain sequence on a piece of paper. Alice's i-th sequence member is i2, Professor Seleznev's i-th sequence member is i3. They decided to create a new ascending sequence by concatenating two of their own sequences. In this case, if both sequences contain the same number, then it is present only once in the new sequence. 

Alice and the professor ask you to guess the i-th number in the new combined sequence. 


Input

The single line of the input file contains a natural number i (1 <= i <= 107).


Output

Print the i-th number of the new sequence. 

 
Examples
# Input Output
1 1 1
2 2 4
3 4 9

ID 45460. Two arrays - 2
Темы: Merge sort   

Alice and her father, Professor Seleznev, write down the numbers on a piece of paper. Alice wrote down n numbers, Professor Seleznev - m numbers. Alice and the professor will be happy if they write down the same numbers (without multiplicity). Help them figure it out as they need to fly off on their next space trip. 
 
Input
The first line contains a number n  (1 <= n <= 100000) is the number of numbers written by Alice. The second line contains n integers whose absolute value does not exceed 109 – Alice's numbers. The third line contains an integer m - the number of numbers written by Professor Seleznev (1 <= m <= 100000) . The fourth line contains m integers whose absolute value does not exceed 109 – Professor Seleznev's numbers.
 
Output
Print YES if the professor and Alice wrote the same numbers, and the word NO  otherwise.
 
 
Examples
# Input Output
1 3
207
4
2 0 0 7
YES

ID 45674. Two arrays
Темы: Merge sort   

Alice and her father Professor Seleznev write down the numbers of a certain sequence on a piece of paper. Alice's i-th sequence member is i2, Professor Seleznev's i-th sequence member is i3. They decided to create a new ascending sequence by concatenating two of their own sequences. In this case, if both sequences contain the same number, then it is present only once in the new sequence. 

Alice and the professor ask you to guess the i-th number in the new combined sequence. 


Input

The single line of the input file contains a natural number i (1 <= i <= 107).


Output

Print the i-th number of the new sequence. 

 
Examples
# Input Output
1 1 1
2 2 4
3 4 9