LogiQuest

366. Merge Two Sorted Lists

EasyLinked ListMerge

Merge two sorted linked lists into one sorted list and print it.

Input format

Line 1: n Line 2: n sorted values Line 3: m Line 4: m sorted values

Output format

The merged list.

Example 1

Input

3
1 2 4
3
1 3 4

Output

1 1 2 3 4 4

Example 2

Input

1
5
2
1 2

Output

1 2 5

Constraints

1 ≤ n, m ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.

Loading the MyLoginn IDE…