E. Echoes on the Endless Line
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
3 2 4 5
4 5 6
1 10
Output
1 5
1 5
Input
5 4 1 3
1 3 5 6 9
2 4 7 8
Output
1 3
2 5
2 4
2 5