Assumption is All You Need
면접 대비시간 제한1초메모리 제한1024 MB
두 순열 A와 B가 주어질 때, A의 역전 쌍을 교환하는 연산만으로 A를 B로 바꾸는 교환 순서를 구하거나 불가능함을 판별한다.
문제
JB holds the belief that assumption is all you need to solve a problem. In order to prove that, JB has given you two permutations of numbers from to : and , and JB wants you to output a sequence of element swapping operation on , so that:
- every pair of swapped element forms an inversion pair (i.e. and when the -th operation is being performed)
- will become at the end of the swapping sequence.
or determine it is impossible. Help prove JB's belief by solving this problem!
입력
There are multiple test cases. The first line of the input contains one integer indicating the number of test cases. For each test case:
The first line contains one integer (), indicating the number elements in and .
The second line contains distinct integers (), indicating the array .
The third line contains distinct integers (), indicating the array .
It is guaranteed that the sum of in all test cases will not exceed .
출력
For each test case, if there doesn't exist a sequence, output the one line containing one integer "-1".
Otherwise, in the first line output one integer (), indicating the length of the swapping sequence. Then, output line each containing two integers and (), indicating the -th operation .