You are given two arrays $a$ and $b$, both consisting of $n$ integers.

In one move, you can choose two indices $i$ and $j$ ($1 \le i, j \le n$; $i \neq j$) and swap $a_i$ with $a_j$ and $b_i$ with $b_j$. You have to perform the swap in both arrays.

You are allowed to perform at most $10^4$ moves (possibly, zero). Can you make both arrays sorted in a non-decreasing order at the end? If you can, print any sequence of moves that makes both arrays sorted.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 100$) — the number of testcases.

The first line of each testcase contains a single integer $n$ ($2 \le n \le 100$) — the number of elements in both arrays.

The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$) — the first array.

The third line contains $n$ integers $b_1, b_2, \dots, b_n$ ($1 \le b_i \le n$) — the second array.


-----Output-----

For each testcase, print the answer. If it's impossible to make both arrays sorted in a non-decreasing order in at most $10^4$ moves, print -1. Otherwise, first, print the number of moves $k$ $(0 \le k \le 10^4)$. Then print $i$ and $j$ for each move $(1 \le i, j \le n$; $i \neq j)$.

If there are multiple answers, then print any of them. You don't have to minimize the number of moves.


-----Examples-----

Input
3
2
1 2
1 2
2
2 1
1 2
4
2 3 1 2
2 3 2 3
Output
0
-1
3
3 1
3 2
4 3


-----Note-----

None

Difficulty: EASY

Solutions:
import sys
input = lambda : sys.stdin.readline().strip()

def is_sorted(a):
	last = a[0]
	for i in a:
		if i < last:
			return False
		last = i
	return True

def good(ab):
	a = [l for (l, r) in ab]
	b = [r for (l, r) in ab]
	return is_sorted(a) and is_sorted(b)

def get_sort_seq(ab, ab_sorted):
	idx = 0
	ans = []
	for pair in ab_sorted:
		cur = ab[idx:].index(pair) + idx
		if cur != idx:
			(ab[idx], ab[cur]) = (ab[cur], ab[idx])
			ans.append((cur + 1, idx + 1))
		idx += 1
	return ans
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ab = [*zip(a, b)]
	ba = [*zip(b, a)]
	if good(sorted(ab)):
		sort_seq = get_sort_seq(ab, sorted(ab))
	elif good(sorted(ba)):
		sort_seq = get_sort_seq(ba, sorted(ba))
	else:
		sort_seq = -1
	if sort_seq == -1:
		print(-1)
	else:
		print(len(sort_seq))
		for pair in sort_seq:
			print(*pair)


N = int(input())
for _ in range(N):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	zipped = list(zip(arr1, arr2, range(1, n + 1)))
	zipped.sort()
	second = [x[1] for x in zipped]
	if second != sorted(second):
		print(-1)
		continue
	third = [x[2] for x in zipped]
	l = list(range(1, n + 1))
	count = 0
	toOutput = []
	for i in range(n):
		if third[i] != l[i]:
			toOutput.append((third[i], l[i]))
			(third[third.index(i + 1)], third[i]) = (third[i], third[third.index(i + 1)])
			count += 1
	print(count)
	for (a, b) in toOutput:
		print(a, b)


t = int(input())
for j in range(t):
	n = int(input())
	a = str(input()).split(' ')
	b = str(input()).split(' ')
	arr = []
	brr = []
	true = []
	inv = []
	for i in range(n):
		arr.append((i, int(a[i]), int(b[i])))
		brr.append((i, int(b[i]), int(a[i])))
		true.append(i)
		inv.append(i)
	arr.sort(key=lambda x: (x[1], x[2]))
	brr.sort(key=lambda x: (x[1], x[2]))
	answer = []
	flag = True
	for i in range(n - 1):
		if arr[i][0] != brr[i][0]:
			flag = False
			break
	if flag:
		for i in range(n - 1):
			if true[arr[i][0]] != i:
				answer.append((true[arr[i][0]], i))
				true[inv[i]] = true[arr[i][0]]
				inv[true[arr[i][0]]] = inv[i]
				true[arr[i][0]] = i
				inv[i] = arr[i][0]
		print(len(answer))
		for i in answer:
			print(i[0] + 1, i[1] + 1)
	else:
		print(-1)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	h = {}
	x = a.copy()
	y = b.copy()
	x.sort()
	y.sort()
	if a == x and b == y:
		print(0)
		t -= 1
		continue
	res = []
	count = 0
	flag = 0
	for i in range(n):
		if a[i] == x[i] and b[i] == y[i]:
			continue
		else:
			for j in range(i + 1, n):
				if a[j] == x[i] and b[j] == y[i]:
					res.append([i, j])
					(a[i], a[j]) = (a[j], a[i])
					(b[i], b[j]) = (b[j], b[i])
					count += 1
					break
		if a[i] == x[i] and b[i] == y[i]:
			continue
		else:
			flag = 1
			break
	if flag == 1:
		print(-1)
	else:
		print(count)
		for i in res:
			print(i[1] + 1, i[0] + 1)
	t -= 1


import sys
import math
from collections import Counter

def gi():
	return list(map(int, sys.stdin.readline().strip().split()))

def gs():
	return sys.stdin.readline().strip()

def fun(a, b):
	l = len(a)
	ans = list(zip(a, b))
	a1 = sorted(a)
	b1 = sorted(b)
	ans1 = list(zip(a1, b1))
	res = []
	for i in range(l):
		if ans[i] == ans1[i]:
			continue
		f = 0
		for j in range(i + 1, l):
			if ans1[i] == ans[j]:
				f = 1
				break
		if f == 0:
			return -1
		(ans[i], ans[j]) = (ans[j], ans[i])
		res.append([j + 1, i + 1])
	return res
for _ in range(int(input())):
	n = input()
	a = gi()
	b = gi()
	x = fun(a, b)
	if x == -1:
		print('-1')
	else:
		print(len(x))
		for i in x:
			print(*i)


def swap_times(c, d, pos, res, times):
	if pos == len(c):
		return (times, res)
	if c[pos] != d[pos]:
		times += 1
		for ii in range(pos, len(a)):
			if c[ii] == d[pos]:
				res.append((ii, pos))
				(c[ii], c[pos]) = (c[pos], c[ii])
				break
	return swap_times(c, d, pos + 1, res, times)

def output(c, d):
	for i in range(len(d) - 1):
		if d[i][1] > d[i + 1][1]:
			print(-1)
			return
	res = []
	times = 0
	ans = swap_times(c, d, 0, res, times)
	print(ans[0])
	for i in range(len(ans[1])):
		print(ans[1][i][0] + 1, ans[1][i][1] + 1)
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	d = []
	for i in range(n):
		c.append((a[i], b[i]))
		d.append((a[i], b[i]))
	d.sort()
	output(c, d)


T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	L = []
	for i in range(n):
		a = i + A[i:].index(min(A[i:]))
		b = i + B[i:].index(min(B[i:]))
		if A[b] == min(A[i:]) and b != i:
			(A[b], A[i]) = (A[i], A[b])
			(B[b], B[i]) = (B[i], B[b])
			L.append([b + 1, i + 1])
		elif B[a] == min(B[i:]) and a != i:
			(A[a], A[i]) = (A[i], A[a])
			(B[a], B[i]) = (B[i], B[a])
			L.append([a + 1, i + 1])
		elif B[a] == min(B[i:]) and a == i:
			pass
		elif A[b] == min(A[i:]) and b == i:
			pass
		else:
			break
	if i != n - 1 or len(L) > 10 ** 4:
		print(-1)
	else:
		print(len(L))
		for i in range(len(L)):
			print(*L[i])


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = []
	cnt = 0
	while cnt < n:
		(ia, ib) = (set(), set())
		(ma, mb) = (101, 101)
		for i in range(cnt, n):
			if A[i] < ma:
				ma = A[i]
				ia = {i}
			elif A[i] == ma:
				ia.add(i)
			if B[i] < mb:
				mb = B[i]
				ib = {i}
			elif B[i] == mb:
				ib.add(i)
		if cnt in ib and cnt in ia:
			cnt += 1
			continue
		prev = len(ans)
		for c in ib:
			if c in ia:
				(A[cnt], A[c]) = (A[c], A[cnt])
				(B[cnt], B[c]) = (B[c], B[cnt])
				ans.append([c + 1, cnt + 1])
				break
		if len(ans) == prev:
			print(-1)
			return
		cnt += 1
	print(len(ans))
	for each in ans:
		print(*each)
	return
for _ in range(int(input())):
	solve()


x = lambda : map(int, input().split())
for t in range(int(input())):
	(n,) = x()
	a = [*x()]
	b = [*x()]
	index = []
	ta = sorted(a)
	tb = sorted(b)
	c = 0
	for i in range(n - 1):
		index_min = i
		for j in range(i + 1, n):
			if a[j] < a[index_min]:
				index_min = j
			elif a[j] == a[index_min]:
				if b[j] < b[index_min]:
					index_min = j
		if index_min != i:
			index.append([index_min + 1, i + 1])
			c += 1
			(temp1, temp2) = (a[i], b[i])
			a[i] = a[index_min]
			a[index_min] = temp1
			b[i] = b[index_min]
			b[index_min] = temp2
	if a != ta or b != tb:
		print(-1)
	else:
		print(c)
		for i in index:
			print(*i)


for i in range(int(input())):
	n = int(input())
	a = [int(k) for k in input().split()]
	b = [int(k) for k in input().split()]
	A = sorted(a)
	B = sorted(b)
	if A == a and B == b:
		print(0)
		continue
	else:
		ANS = []
		for k in range(n):
			if a[k] != A[k]:
				for j in range(k + 1, n):
					if A[k] == a[j] and B[k] == b[j]:
						ANS.append([j + 1, k + 1])
						(a[j], a[k]) = (a[k], a[j])
						(b[j], b[k]) = (b[k], b[j])
			if b[k] != B[k]:
				for j in range(k + 1, n):
					if A[k] == a[j] and B[k] == b[j]:
						ANS.append([j + 1, k + 1])
						(a[j], a[k]) = (a[k], a[j])
						(b[j], b[k]) = (b[k], b[j])
		if b == B and a == A:
			print(len(ANS))
			for k in ANS:
				print(*k)
		else:
			print(-1)


t = int(input())
for j in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = a.copy()
	d = b.copy()
	c.sort()
	d.sort()
	p = []
	g = []
	v = []
	op = []
	s = 0
	fo = -1
	for k in range(0, n):
		p.append(str(a[k]) + ' ' + str(b[k]))
		g.append(str(c[k]) + ' ' + str(d[k]))
		if p[-1] == g[-1]:
			s += 1
		v.append(0)
		op.append(0)
	if s != n:
		for i in range(0, n):
			fo = -1
			for k in range(0, n):
				if v[k] == 0:
					if p[k] == g[i]:
						v[k] = 1
						op[k] = i
						fo = 0
						break
				else:
					continue
			if fo == -1:
				print(-1)
				break
		bb = []
		cc = 0
		if fo != -1:
			for i in range(0, n):
				mi = i
				for k in range(i + 1, n):
					if op[mi] > op[k]:
						mi = k
				(op[i], op[mi]) = (op[mi], op[i])
				if mi != i:
					cc += 1
					bb.append(str(mi + 1) + ' ' + str(i + 1))
			print(cc)
			for i in bb:
				print(i)
	else:
		print(0)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = sorted(a)
	sb = sorted(b)
	if a == sa and b == sb:
		print(0)
		return
	pairs = []
	for i in range(n):
		for j in range(i + 1, n):
			if b[j] <= b[i] and a[j] <= a[i]:
				pairs.append([j + 1, i + 1])
				(a[i], a[j]) = (a[j], a[i])
				(b[i], b[j]) = (b[j], b[i])
			if len(pairs) > 10 ** 4:
				print(-1)
				return
	if a == sa and b == sb:
		print(len(pairs))
		for (i, j) in pairs:
			print(i, j)
		return
	print(-1)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lst = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			if a[i] > a[j] or b[i] > b[j]:
				(a[i], a[j]) = (a[j], a[i])
				(b[i], b[j]) = (b[j], b[i])
				lst.append((j + 1, i + 1))
	if b == sorted(b) and a == sorted(a):
		print(len(lst))
		for (i, j) in lst:
			print(i, j)
	else:
		print(-1)


def sort(a, b):
	x = []
	for i in range(len(a)):
		for j in range(i, len(a)):
			if a[j] < a[i]:
				(a[i], a[j]) = (a[j], a[i])
				(b[i], b[j]) = (b[j], b[i])
				x.append([j + 1, i + 1])
	for i in range(len(a)):
		for j in range(i, len(a)):
			if b[j] < b[i]:
				(a[i], a[j]) = (a[j], a[i])
				(b[i], b[j]) = (b[j], b[i])
				x.append([j + 1, i + 1])
	if b != sorted(b) or a != sorted(a):
		return -1
	else:
		return x
for _ in range(int(input())):
	k = int(input())
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	z = sort(arr1, arr2)
	if z == -1:
		print(-1)
	elif len(z) == 0:
		print(0)
	else:
		print(len(z))
		for x in z:
			print(*x)


for e in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	for i in range(n):
		for j in range(i + 1, n):
			if a[j] < a[i] or b[j] < b[i]:
				res.append((j + 1, i + 1))
				(b[i], b[j]) = (b[j], b[i])
				(a[j], a[i]) = (a[i], a[j])
	if not (a == sorted(a) and b == sorted(b)):
		print(-1)
		continue
	print(len(res))
	for i in res:
		print(*i)


for i in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	res = []
	c = 0
	for i in range(n):
		for j in range(i + 1, n):
			if arr1[j] < arr1[i]:
				(arr1[i], arr1[j]) = (arr1[j], arr1[i])
				(arr2[i], arr2[j]) = (arr2[j], arr2[i])
				res.append([j + 1, i + 1])
				c = 1
			elif arr1[j] == arr1[i]:
				if arr2[j] < arr2[i]:
					(arr1[i], arr1[j]) = (arr1[j], arr1[i])
					(arr2[i], arr2[j]) = (arr2[j], arr2[i])
					res.append([j + 1, i + 1])
					c = 1
	if sorted(arr1) == arr1 and sorted(arr2) == arr2:
		if c == 0:
			print(0)
		else:
			print(len(res))
			for i in range(len(res)):
				ans = res[i]
				print(ans[0], ans[1])
	else:
		print(-1)