5515: CF EDU - Two Pointer Method - Step 3 - D. Stylish clothes
[Creator : ]
Description
Gleb loves shopping. Once, he got the idea to choose a cap, a shirt, pants and shoes so that they look as stylish as possible. In Gleb's understanding clothes are more stylish when the difference in color of the elements of his clothes is small.
There are $n_1$ caps, $n_2$ shirts, $n_3$ pants and $n_4$ shoes ($1 ≤n_i≤ 100, 000$). Each clothes element has its color (an integer from 1 to 100, 000). A set of clothes is one cap, shirt, pants and one pair of boots. Each set is characterized by the maximum difference between any two of its elements. Help Gleb to choose the most stylish set, that is the set with the minimum color difference.
There are $n_1$ caps, $n_2$ shirts, $n_3$ pants and $n_4$ shoes ($1 ≤n_i≤ 100, 000$). Each clothes element has its color (an integer from 1 to 100, 000). A set of clothes is one cap, shirt, pants and one pair of boots. Each set is characterized by the maximum difference between any two of its elements. Help Gleb to choose the most stylish set, that is the set with the minimum color difference.
Input
For each clothes element $i\ (i= 1, 2, 3, 4)$ given its count n$i_,$ and $n_i$ integers in next line which is their color. First clothes element in input is caps, second is shirts, third is pants and forth is shoes. All numbers in input are positive integers not bigger than 100, 000.
Output
Write 4 integers in output, color of cap, shirt, pants and shoes Gleb will choose. If there are several most stylish sets output any of them.
Sample 1 Input
3
1 2 3
2
1 3
2
3 4
2
2 3
Sample 1 Output
3 3 3 3
Sample 2 Input
1
5
4
3 6 7 10
4
18 3 9 11
1
20
Sample 2 Output
5 6 9 20