Messy Kevin
Kevin from the IT team was tasked with syncing server logs from two machines. As usual, he messed it up. Instead of keeping the logs in one neat sequence, he dumped parts of the logs into two separate files. Now you've been called in to clean up the mess and merge the logs properly.
Each log file was already sorted before Kevin touched them, but we need them to be in a single file for our analysis. Your job is to merge the two log files into a single chronologic, neat, and tidy sequence.
Kevin's counting on you. (Mostly because he doesn't know how to fix it himself.)
Input
The first line contains two space-separated integers , representing the number of elements in files
and file
respectively.
The second line contains space-separated integers
, representing the
th element in file
.
The third line contains space-separated integers
, representing the
th element in file
.
Output
Print the merged file in non-decreasing order - a single line of space-separated integers of length .
The time complexity of your solution must be linear in the input lengths - - or faster.
Example
Input 1
3 4
1 2 3
2 5 6 7
Output 1
1 2 2 3 5 6 7
Input 2
2 3
8 0
0 1 2
Output 2
0 0 1 2 8
Comments