D. Duo of Magicians
time limit per test
1.5 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Example
Input
3
5
1 3 5 2 4
6
6 5 4 3 2 1
3
1 2 3
Output
3
2 3
2 4
4 5
5
3 4
2 5
1 2
1 6
1 2
0