AquaMoon and Cirno are playing an interesting game with arrays. Cirno has prepared two arrays $a$ and $b$, both consist of $n$ non-negative integers. AquaMoon can perform the following operation an arbitrary number of times (possibly zero):

She chooses two indices $i$ and $j$ ($1 \le i, j \le n$), then decreases the $i$-th element of array $a$ by $1$, and increases the $j$-th element of array $a$ by $1$. The resulting values at $i$-th and $j$-th index of array $a$ are $a_i - 1$ and $a_j + 1$, respectively. Each element of array $a$ must be non-negative after each operation. If $i = j$ this operation doesn't change the array $a$.

AquaMoon wants to make some operations to make arrays $a$ and $b$ equal. Two arrays $a$ and $b$ are considered equal if and only if $a_i = b_i$ for all $1 \leq i \leq n$.

Help AquaMoon to find a sequence of operations that will solve her problem or find, that it is impossible to make arrays $a$ and $b$ equal.

Please note, that you don't have to minimize the number of operations.


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 100$) — the number of test cases.

The first line of each test case contains a single integer $n$ ($1 \leq n \leq 100$).

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \leq a_i \leq 100$). The sum of all $a_i$ does not exceed $100$.

The third line of each test case contains $n$ integers $b_1, b_2, \dots, b_n$ ($0 \leq b_i \leq 100$). The sum of all $b_i$ does not exceed $100$.


-----Output-----

For each test case print "-1" on the only line if it is impossible to make two arrays equal with some sequence of operations.

Otherwise, print an integer $m$ ($0 \leq m \leq 100$) in the first line — the number of operations. Then print $m$ lines, each line consists of two integers $i$ and $j$ — the indices you choose for the operation.

It can be proven that if it is possible to make two arrays equal with some sequence of operations, there exists a sequence with $m \leq 100$.

If there are multiple possible solutions, you can print any.


-----Examples-----

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


-----Note-----

In the first example, we do the following operations:

$i = 2$, $j = 1$: $[1, 2, 3, 4] \rightarrow [2, 1, 3, 4]$;

$i = 3$, $j = 1$: $[2, 1, 3, 4] \rightarrow [3, 1, 2, 4]$;

In the second example, it's impossible to make two arrays equal.

Difficulty: EASY

Solutions:
import sys
input = sys.stdin.readline

def I():
	return input().strip()

def II():
	return int(input().strip())

def LI():
	return [*map(int, input().strip().split())]
import copy
import re
import string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter, OrderedDict
from itertools import permutations, combinations, groupby, count, filterfalse
from operator import itemgetter
for _ in range(II()):
	n = II()
	a = LI()
	b = LI()
	inc = []
	dec = []
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		if a[i] < b[i]:
			x = b[i] - a[i]
			inc = inc + [i + 1] * x
		elif a[i] > b[i]:
			y = a[i] - b[i]
			dec = dec + [i + 1] * y
	print(len(inc))
	for i in range(len(inc)):
		print(dec[i], inc[i])


for _ in range(int(input())):
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if sum(l1) != sum(l2):
		print(-1)
	else:
		l = []
		r = []
		for i in range(n):
			if l1[i] < l2[i]:
				l.extend([i + 1] * (l2[i] - l1[i]))
			elif l1[i] > l2[i]:
				r.extend([i + 1] * (l1[i] - l2[i]))
		if len(l) != 0:
			print(len(l))
			for i in range(len(l)):
				print(r[i], l[i])
		else:
			print(0)


def arrays(n, arr1, arr2):
	if arr1 == arr2:
		print('0')
		return
	count = 0
	results = []
	while arr1 != arr2:
		ri = -1
		rj = -1
		for i in range(n):
			a1 = arr1[i]
			a2 = arr2[i]
			if ri == -1 and a1 - 1 >= a2:
				ri = i
			if rj == -1 and a1 + 1 <= a2:
				rj = i
		if ri > -1 and rj > -1:
			arr1[ri] = arr1[ri] - 1
			arr1[rj] = arr1[rj] + 1
			count += 1
			results.append(f'{ri + 1} {rj + 1}')
		else:
			break
	if arr1 != arr2:
		print('-1')
	else:
		print(count)
		print('\n'.join(results))
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arrays(n, a, b)


for i in range(int(input())):
	n = int(input())
	lisa = list(map(int, input().split(' ')))
	lisb = list(map(int, input().split(' ')))
	if lisa == lisb:
		print(0)
	elif sum(lisa) == sum(lisb):
		pos = []
		neg = []
		idx = 1
		for (a, b) in zip(lisa, lisb):
			if a - b > 0:
				pos.append([a - b, idx])
			elif a - b < 0:
				neg.append([a - b, idx])
			idx += 1
		res = []
		count = 0
		while pos and neg:
			res.append([pos[-1][1], neg[-1][1]])
			pos[-1][0] -= 1
			neg[-1][0] += 1
			if pos[-1][0] == 0:
				pos.pop()
			if neg[-1][0] == 0:
				neg.pop()
			count += 1
		print(count)
		for (i, j) in res[::-1]:
			print(i, j)
	else:
		print(-1)


for i in range(int(input())):
	_ = int(input())
	z = []
	pos = []
	neg = []
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in range(_):
		z.append(a[j] - b[j])
	if sum(z) != 0:
		print('-1')
		continue
	elif z == [0] * _:
		print('0')
		continue
	else:
		sum1 = 0
		for l in range(len(z)):
			if z[l] > 0:
				sum1 += z[l]
				pos.extend([l + 1] * z[l])
			elif z[l] < 0:
				neg.extend([l + 1] * abs(z[l]))
		print(sum1)
		for f in range(len(pos)):
			print(pos[f], neg[f])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ops = []
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		dif1 = a[i] - b[i]
		if dif1 < 0:
			for j in range(i + 1, n):
				dif2 = a[j] - b[j]
				if dif2 > 0:
					while dif2 > 0 and dif1 < 0:
						a[j] -= 1
						dif2 -= 1
						a[i] += 1
						dif1 += 1
						ops.append((j + 1, i + 1))
					if dif1 == 0:
						break
		elif dif1 > 0:
			for j in range(i + 1, n):
				dif2 = a[j] - b[j]
				if dif2 < 0:
					while dif2 < 0 and dif1 > 0:
						a[j] += 1
						dif2 += 1
						a[i] -= 1
						dif1 -= 1
						ops.append((i + 1, j + 1))
					if dif1 == 0:
						break
	print(len(ops))
	for op in ops:
		print(*op)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	d = []
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		if a[i] > b[i]:
			for j in range(a[i] - b[i]):
				c.append(i + 1)
		if a[i] < b[i]:
			for j in range(b[i] - a[i]):
				d.append(i + 1)
	l = len(c)
	print(l)
	for i in range(l):
		print(c[i], d[i])


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	ans = 0
	if sum(a) != sum(b):
		print(-1)
	else:
		ans = 0
		arr = []
		for i in range(n):
			j = i + 1
			while j < n and a[i] != b[i]:
				if a[i] > b[i] and a[j] >= b[j] or (a[i] < b[i] and a[j] <= b[j]):
					j += 1
					continue
				while a[j] != b[j] and a[i] != b[i]:
					if a[i] > b[i]:
						a[i] -= 1
						a[j] += 1
						arr.append([i + 1, j + 1])
					else:
						a[i] += 1
						a[j] -= 1
						arr.append([j + 1, i + 1])
					ans += 1
				j += 1
		print(ans)
		for a in arr:
			print(*a)


n = int(input())
for i in range(n):
	x = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l1 = []
	l2 = []
	if sum(a) != sum(b):
		print(-1)
	else:
		for j in range(x):
			if a[j] > b[j]:
				l1.extend([j + 1] * (a[j] - b[j]))
			elif b[j] > a[j]:
				l2.extend([j + 1] * (b[j] - a[j]))
		if len(l1) == 0:
			print(0)
		else:
			print(len(l2))
			for k in range(len(l2)):
				print(l1[k], l2[k])


t = int(input())
for i in range(t):
	l = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print(0)
		continue
	r = []
	rc = 0
	for j in range(l):
		if a[j] > b[j]:
			for k in range(j + 1, l):
				if a[k] < b[k]:
					tmp = min([abs(a[j] - b[j]), abs(a[k] - b[k])])
					r.append([str(j + 1) + ' ' + str(k + 1), tmp])
					a[j] -= tmp
					a[k] += tmp
					rc += tmp
					if a[j] == 0:
						break
		elif a[j] < b[j]:
			for k in range(j + 1, l):
				if a[k] > b[k]:
					tmp = min([abs(a[j] - b[j]), abs(a[k] - b[k])])
					r.append([str(k + 1) + ' ' + str(j + 1), tmp])
					a[j] += tmp
					a[k] -= tmp
					rc += tmp
					if a[j] == 0:
						break
	if a != b:
		print(-1)
	else:
		print(rc)
		for j in r:
			for k in range(j[1]):
				print(j[0])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	else:
		less = []
		more = []
		for i in range(n):
			if a[i] == b[i]:
				pass
			elif a[i] > b[i]:
				more.extend([i] * abs(b[i] - a[i]))
			else:
				less.extend([i] * abs(b[i] - a[i]))
		if len(more) != len(less):
			print(-1)
			continue
		else:
			print(len(more))
			for i in range(len(more)):
				print(more[i] + 1, less[i] + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a_string = input()
	b_string = input()
	a = a_string.split(' ')
	b = b_string.split(' ')
	a = [int(a[j]) for j in range(n)]
	b = [int(b[j]) for j in range(n)]
	d = [a[j] - b[j] for j in range(n)]
	if sum(d) != 0:
		print(-1)
		continue
	aless = []
	bless = []
	k = 0
	for j in range(n):
		if d[j] < 0:
			aless.append(j)
		elif d[j] > 0:
			bless.append(j)
			k += d[j]
	iarr = []
	jarr = []
	jp = 0
	ip = 0
	for j in range(k):
		d[aless[ip]] += 1
		d[bless[jp]] -= 1
		iarr.append(bless[jp] + 1)
		jarr.append(aless[ip] + 1)
		if d[aless[ip]] == 0:
			ip += 1
		if d[bless[jp]] == 0:
			jp += 1
	m = len(iarr)
	print(m)
	for j in range(m):
		print(iarr[j], jarr[j])


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = []
	neg = []
	if sum(a) != sum(b):
		print(-1)
	else:
		for i in range(n):
			if b[i] - a[i] > 0:
				for j in range(b[i] - a[i]):
					pos.append(i + 1)
			elif b[i] - a[i] < 0:
				for j in range(a[i] - b[i]):
					neg.append(i + 1)
		print(len(pos))
		for i in range(len(pos)):
			print(neg[i], pos[i])


from collections import Counter
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s1 = sum(a)
	s2 = sum(b)
	if s1 == s2:
		m = 0
		s = []
		for j in range(n - 1):
			x = abs(a[j] - b[j])
			if a[j] < b[j]:
				for k in range(j + 1, n):
					while a[k] > b[k] and x > 0:
						a[k] -= 1
						s.append([k + 1, j + 1])
						x -= 1
						m += 1
					if x == 0:
						break
			elif a[j] > b[j]:
				for k in range(j + 1, n):
					while a[k] < b[k] and x > 0:
						a[k] += 1
						s.append([j + 1, k + 1])
						x -= 1
						m += 1
					if x == 0:
						break
			a[j] = b[j]
		print(m)
		for j in s:
			print(j[0], j[1])
	else:
		print(-1)


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if sum(arr) != sum(arr2):
		print(-1)
		return
	ops = []
	for i in range(len(arr)):
		if arr[i] > arr2[i]:
			left = arr[i] - arr2[i]
			for j in range(i + 1, len(arr)):
				if arr[j] >= arr2[j]:
					continue
				for k in range(min(arr2[j] - arr[j], left)):
					left -= 1
					arr[j] += 1
					ops.append([i + 1, j + 1])
		elif arr[i] < arr2[i]:
			left = arr2[i] - arr[i]
			for j in range(i + 1, len(arr)):
				if arr[j] <= arr2[j]:
					continue
				for k in range(min(arr[j] - arr2[j], left)):
					left -= 1
					arr[j] -= 1
					ops.append([j + 1, i + 1])
	print(len(ops))
	for i in ops:
		print(i[0], i[1])
for i in range(t):
	solve()


def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if sum(a) != sum(b):
		print(-1)
		return None
	(pos, neg) = ([], [])
	for i in range(n):
		if a[i] > b[i]:
			pos.append(i)
		elif a[i] < b[i]:
			neg.append(i)
	cnt = 0
	oper = []
	while pos != [] and neg != []:
		ind = pos[0]
		while a[ind] > b[ind]:
			indX = neg[0]
			a[ind] -= 1
			a[indX] += 1
			if a[indX] == b[indX]:
				del neg[0]
			cnt += 1
			oper.append([ind, indX])
		del pos[0]
	print(cnt)
	for el in oper:
		print(el[0] + 1, el[1] + 1)
t = int(input())
for _ in range(t):
	solve()


def main():
	for q in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if sum(a) != sum(b):
			print(-1)
			continue
		dif = [a[i] - b[i] for i in range(n)]

		def nextp(ind, mean):
			for i in range(ind, n):
				if dif[i] * mean > 0:
					return i
		m = 0
		for x in dif:
			if x > 0:
				m += x
		pos = nextp(0, 1)
		neg = nextp(0, -1)
		print(m)
		while m > 0:
			if dif[pos] > 0 and dif[neg] < 0:
				print(pos + 1, neg + 1)
				dif[pos] -= 1
				dif[neg] += 1
				m -= 1
			elif dif[pos] == 0:
				pos = nextp(pos, 1)
			elif dif[neg] == 0:
				neg = nextp(neg, -1)
main()


t = int(input())
for ele in range(t):
	n = int(input())
	foo = [int(i) for i in input().split()]
	bar = [int(i) for i in input().split()]
	minus = 0
	plus = 0
	a = []
	b = []
	for i in range(n):
		if foo[i] - bar[i] < 0:
			minus += foo[i] - bar[i]
			for j in range(abs(foo[i] - bar[i])):
				a.append(i + 1)
		elif foo[i] - bar[i] > 0:
			plus += foo[i] - bar[i]
			for j in range(abs(foo[i] - bar[i])):
				b.append(i + 1)
	if minus == 0 and plus == 0:
		print(0)
	elif minus + plus != 0:
		print(-1)
	elif minus + plus == 0:
		print(plus)
		for i in range(plus):
			print(b[i], a[i])


from sys import stdin as si, stdout as so
for _ in range(int(si.readline())):
	n = int(si.readline())
	a = list(map(int, si.readline().split()))
	b = list(map(int, si.readline().split()))
	if n == 1:
		if a[0] == b[0]:
			so.write(str(0) + '\n')
		else:
			so.write(str(-1) + '\n')
		continue
	elif a == b:
		so.write(str(0) + '\n')
		continue
	c = []
	d = []
	q = []
	w = []
	for i in range(n):
		if a[i] < b[i]:
			c += [abs(a[i] - b[i])]
			q += [i]
		elif a[i] > b[i]:
			d += [abs(a[i] - b[i])]
			w += [i]
	if sum(c) != sum(d):
		so.write(str(-1) + '\n')
	else:
		o = []
		p = []
		k = sum(c)
		for i in range(len(c)):
			for j in range(c[i]):
				o += [q[i] + 1]
		for i in range(len(d)):
			for j in range(d[i]):
				p += [w[i] + 1]
		so.write(str(sum(c)) + '\n')
		for i in range(k):
			so.write(str(p[i]) + ' ' + str(o[i]) + '\n')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	(inc, dec) = ([], [])
	for i in range(n):
		if a[i] != b[i]:
			if a[i] < b[i]:
				inc += [i + 1] * (b[i] - a[i])
			else:
				dec += [i + 1] * (a[i] - b[i])
	if len(inc) != len(dec):
		print(-1)
	else:
		print(len(inc))
		for (i, j) in zip(inc, dec):
			print(j, i)


PI = 3.141592653589793
INF = float('inf')
MOD = 1000000007

def bin32(num):
	return '{0:032b}'.format(num)

def add(x, y):
	return (x + y) % MOD

def sub(x, y):
	return (x - y + MOD) % MOD

def mul(x, y):
	return x * y % MOD

def gcd(x, y):
	if y == 0:
		return x
	return gcd(y, x % y)

def lcm(x, y):
	return x * y // gcd(x, y)

def power(x, y):
	res = 1
	x %= MOD
	while y != 0:
		if y & 1:
			res = mul(res, x)
		y >>= 1
		x = mul(x, x)
	return res

def mod_inv(n):
	return power(n, MOD - 2)

def prob(p, q):
	return mul(p, power(q, MOD - 2))

def ii():
	return int(input())

def li():
	return [int(i) for i in input().split()]

def ls():
	return [i for i in input().split()]
for t in range(ii()):
	t += 1
	n = ii()
	a = li()
	b = li()
	pos = []
	neg = []
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		if a[i] < b[i]:
			neg.append(i)
		elif a[i] > b[i]:
			pos.append(i)
	ans = []
	for i in pos:
		diff = a[i] - b[i]
		ind = 0
		while diff > 0:
			x = neg[ind]
			if a[x] < b[x]:
				a[x] += 1
				ans.append([i + 1, x + 1])
				diff -= 1
			else:
				ind += 1
	print(len(ans))
	for i in ans:
		print(*i)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	plal = []
	slal = []
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		if a[i] < b[i]:
			plal += [i + 1] * (b[i] - a[i])
		elif b[i] < a[i]:
			slal += [i + 1] * (a[i] - b[i])
	print(len(plal))
	for i in range(len(plal)):
		print(slal[i], plal[i])


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print(0)
		continue
	minus = 0
	plus = 0
	ans1 = []
	ans2 = []
	for i in range(n):
		if a[i] > b[i]:
			diff = a[i] - b[i]
			minus += diff
			ans1.extend([i + 1] * diff)
		elif a[i] < b[i]:
			diff = b[i] - a[i]
			plus += diff
			ans2.extend([i + 1] * diff)
	if plus != minus:
		print(-1)
	else:
		print(plus)
		for i in range(len(ans1)):
			print(ans1[i], ans2[i])


nt = int(input())
ans = []

def soln(a, b, num):
	if a == b:
		return 0
	if num == 1:
		if a[0] != b[0]:
			return -1
		else:
			return 0
	sump = 0
	sumn = 0
	p = []
	n = []
	i = 0
	j = 0
	ans = []
	for x in range(num):
		diff = a[x] - b[x]
		if diff > 0:
			p.append([diff, x])
			sump = sump + diff
		elif diff < 0:
			n.append([diff, x])
			sumn = sumn - diff
	if sump != sumn:
		return -1
	sumn = 0
	while True:
		if p[i][0] == 0:
			i = i + 1
		if n[j][0] == 0:
			j = j + 1
		if i == len(p) or j == len(n):
			break
		p[i][0] = p[i][0] - 1
		n[j][0] = n[j][0] + 1
		ans.append([p[i][1] + 1, n[j][1] + 1])
	return ans
for x in range(nt):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans.append(soln(a, b, n))
for an in ans:
	if an == -1 or an == 0:
		print(an)
		continue
	else:
		print(len(an))
		for x in an:
			print(x[0], x[1])


for t in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	diff = [i - j for (i, j) in zip(a, b)]
	if sum(diff) != 0:
		print(-1)
		continue
	remove = [0] * n
	add = [0] * n
	for i in range(n):
		if diff[i] > 0:
			add[i] += diff[i]
		elif diff[i] < 0:
			remove[i] -= diff[i]
	changes = sum(map(abs, diff)) // 2
	print(changes)
	l = r = 0
	for i in range(changes):
		while not remove[l]:
			l += 1
		while not add[r]:
			r += 1
		print(r + 1, l + 1)
		add[r] -= 1
		remove[l] -= 1


import os
import sys
import math
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		m = 0
		a = [int(x) for x in sys.stdin.readline().split()]
		b = [int(x) for x in sys.stdin.readline().split()]
		iarr = []
		jarr = []
		flag = 0
		if sum(a) != sum(b):
			print(-1)
			continue
		elif a == b:
			print(0)
			continue
		else:
			i = 0
			while i < len(a):
				if a[i] > b[i]:
					flag = 1
					while True:
						if a[i] == b[i]:
							break
						a[i] -= 1
						j = 0
						while j < len(a):
							if a[j] < b[j]:
								a[j] += 1
								m += 1
								iarr.append(i + 1)
								jarr.append(j + 1)
								break
							j += 1
				if flag == 1:
					flag = 0
					i = 0
				else:
					i += 1
			if a == b:
				print(m)
				for i in range(m):
					print(iarr[i], jarr[i], sep=' ')
			else:
				print(-1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = [0] * n
	(pos, neg) = ([], [])
	for i in range(n):
		if a[i] == b[i]:
			arr[i] = 0
		else:
			arr[i] = b[i] - a[i]
			if arr[i] > 0:
				pos.extend([i + 1] * arr[i])
			else:
				neg.extend([i + 1] * abs(arr[i]))
	if sum(arr) != 0:
		print(-1)
	elif len(pos) == 0:
		print(0)
	else:
		print(len(pos))
		for i in range(len(pos)):
			print(neg[i], pos[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = []
	for i in range(len(a)):
		c.append(a[i] - b[i])
	if sum(c) != 0:
		print(-1)
		continue
	p = []
	m = []
	for i in range(n):
		if c[i] > 0:
			for x in range(abs(c[i])):
				p.append(i + 1)
		if c[i] < 0:
			for x in range(abs(c[i])):
				m.append(i + 1)
	print(len(p))
	for i in range(len(p)):
		print(p[i], m[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	c = 0
	if len(a) == 1:
		if a[0] == b[0]:
			print(0)
		else:
			print(-1)
	else:
		x = []
		y = []
		for i in range(n):
			if a[i] > b[i]:
				x += [i + 1] * (a[i] - b[i])
				c += a[i] - b[i]
			elif b[i] > a[i]:
				y += [i + 1] * (b[i] - a[i])
				c += a[i] - b[i]
		if c == 0:
			print(len(x))
			for j in range(len(x)):
				print(x[j], y[j])
		else:
			print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	elif a == b:
		print(0)
	else:
		(d, c) = ([], [])
		for i in range(n):
			if a[i] != b[i]:
				if b[i] - a[i] > 0:
					for j in range(b[i] - a[i]):
						d.append(i + 1)
				else:
					for j in range(a[i] - b[i]):
						c.append(i + 1)
		if len(d) == len(c):
			print(len(d))
			for i in range(len(d)):
				print(c[i], d[i])
		else:
			print(-1)


t = int(input())

def compute(a, b, n):
	if sum(a) != sum(b):
		print(-1)
		return
	res = []
	count = 0
	for i in range(n):
		for j in range(n):
			while a[j] < b[j] and a[i] > b[i]:
				a[j] += 1
				a[i] -= 1
				count += 1
				res.append([i + 1, j + 1])
	print(count)
	for x in res:
		print(x[0], x[1])
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	compute(a, b, n)


t = int(input())
for i in range(t):
	len1 = int(input())
	array1 = [int(i) for i in input().split()]
	array2 = [int(i) for i in input().split()]
	if sum(array1) == sum(array2):
		increaseindex = []
		decreaseindex = []
		for j in range(len1):
			if array1[j] < array2[j]:
				for k in range(array2[j] - array1[j]):
					increaseindex.append(j)
			elif array1[j] > array2[j]:
				for k in range(array1[j] - array2[j]):
					decreaseindex.append(j)
		print(len(increaseindex))
		for j in range(len(increaseindex)):
			print(f'{decreaseindex[j] + 1} {increaseindex[j] + 1}')
	else:
		print('-1')


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(a) for a in input().split()]
	b = [int(b) for b in input().split()]
	s = []
	u = 0
	polj = []
	otri = []
	counter = 0
	for i in range(n):
		s.append(a[i] - b[i])
	if sum(s) != 0:
		print(-1)
	else:
		while u != len(s):
			if s[u] < 0:
				s[u] = s[u] + 1
				polj.append(u + 1)
				counter += 1
			elif s[u] > 0:
				s[u] = s[u] - 1
				otri.append(u + 1)
				counter += 1
			else:
				u += 1
		print(counter // 2)
		for i in range(len(otri)):
			print(otri[i], polj[i])


t = int(input())
for _ in range(t):
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	else:
		minus = []
		plus = []
		for i in range(len(a)):
			if a[i] > b[i]:
				minus.extend([i + 1] * (a[i] - b[i]))
			elif a[i] < b[i]:
				plus.extend([i + 1] * (b[i] - a[i]))
		if len(minus) == 0:
			print(0)
		else:
			ops = [f'{str(x)} {str(y)}' for (x, y) in zip(minus, plus)]
			print(len(ops))
			print('\n'.join(ops))


def s1():
	t = int(input())
	arr = []
	for i in range(t):
		n = int(input())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		if a == b:
			arr.append('0')
			continue
		xl = []
		xr = []
		for k in range(n):
			m = a[k] - b[k]
			if m == 0:
				continue
			if m < 0:
				for d in range(-m):
					xr.append(k + 1)
			if m > 0:
				for d in range(m):
					xl.append(k + 1)
		if len(xl) != len(xr):
			arr.append('-1')
			continue
		arr.append(len(xl))
		for d in range(len(xl)):
			arr.append('{} {}'.format(xl[d], xr[d]))
	for el in arr:
		print(el)
s1()


import sys
import io, os
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if sum(A) != sum(B):
		print(-1)
		continue
	ans = []
	U = []
	L = []
	for i in range(n):
		if A[i] > B[i]:
			U.append((i, A[i] - B[i]))
		elif A[i] < B[i]:
			L += [i] * (B[i] - A[i])
	cur = 0
	for (i, c) in U:
		for j in range(cur, cur + c):
			ans.append((i + 1, L[j] + 1))
		cur += c
	m = len(ans)
	print(m)
	for i in range(m):
		print(*ans[i])


t = int(input())
for _ in range(t):
	m = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	pos = []
	neg = []
	D = []
	for i in range(len(A)):
		D.append(B[i] - A[i])
		if B[i] - A[i] > 0:
			pos += [i] * (B[i] - A[i])
		else:
			neg += [i] * (-B[i] + A[i])
	if sum(D) != 0:
		print(-1)
	else:
		print(len(pos))
		for j in range(len(pos)):
			print(neg[j] + 1, pos[j] + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	minuses = []
	pluses = []
	index = 0
	for (i, j) in zip(a, b):
		if i < j:
			for _ in range(j - i):
				minuses.append(index)
		elif i > j:
			for _ in range(i - j):
				pluses.append(index)
		index += 1
	if len(minuses) != len(pluses):
		print(-1)
	else:
		print(len(pluses))
		for k in range(len(pluses)):
			print(pluses[k] + 1, minuses[k] + 1)


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	(ls, lst, bs, bst) = ([], [], [], [])
	for i in range(n):
		if a[i] < b[i]:
			ls.append(i)
			lst.append(b[i] - a[i])
		elif a[i] > b[i]:
			bs.append(i)
			bst.append(a[i] - b[i])
	seq = []
	i = 0
	j = 0
	while i < len(lst) and j < len(bst):
		seq.append([bs[j] + 1, ls[i] + 1])
		bst[j] -= 1
		lst[i] -= 1
		if not bst[j]:
			j += 1
		if not lst[i]:
			i += 1
	print(len(seq))
	for i in seq:
		print(*i)


def check_if_possible(a, b):
	(plus, minus) = (0, 0)
	for i in range(len(a)):
		if a[i] > b[i]:
			minus += a[i] - b[i]
		elif a[i] < b[i]:
			plus += b[i] - a[i]
	if plus == minus:
		return plus
	return -1

def solve(a, b):
	plus_inds = [i for i in range(len(a)) if a[i] < b[i]]
	minus_inds = [i for i in range(len(a)) if a[i] > b[i]]
	while a != b:
		p = plus_inds[0]
		m = minus_inds[0]
		a[p] += 1
		a[m] -= 1
		print(m + 1, p + 1)
		if a[p] == b[p]:
			if len(a) == 1:
				break
			plus_inds = plus_inds[1:]
		if a[m] == b[m]:
			if len(b) == 1:
				break
			minus_inds = minus_inds[1:]
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	res1 = check_if_possible(a, b)
	print(res1)
	if res1 != -1 and res1 != 0:
		solve(a, b)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	li = []
	if sum(a) == sum(b):
		li1 = []
		for i in range(n):
			li.append(a[i] - b[i])
		for i in range(n):
			for j in range(i + 1, n):
				if li[i] > 0 and li[j] < 0:
					y = min(li[i], abs(li[j]))
					li[i] -= y
					li[j] += y
					for k in range(y):
						li1.append([i + 1, j + 1])
			for j in range(i + 1, n):
				if li[i] < 0 and li[j] > 0:
					y = min(abs(li[i]), li[j])
					li[i] += y
					li[j] -= y
					for k in range(y):
						li1.append([j + 1, i + 1])
		print(len(li1))
		for i in range(len(li1)):
			print(*li1[i])
	else:
		print(-1)


x = int(input())
for i in range(x):
	y = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = []
	pos_sum = 0
	for j in range(y):
		z = a[j] - b[j]
		c.append(z)
		if z > 0:
			pos_sum += z
	if sum(c) != 0:
		print(-1)
	else:
		print(pos_sum)
		p1 = 0
		p2 = 0
		while p1 < y:
			if c[p1] < 0 and c[p2] > 0:
				c[p1] += 1
				c[p2] -= 1
				print(p2 + 1, p1 + 1)
			elif c[p1] == 0:
				p1 += 1
			elif c[p2] == 0:
				p2 += 1
			elif c[p1] > 0:
				p1 += 1
			elif c[p2] < 0:
				p2 += 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if sum(a) != sum(b):
		print(-1)
		continue
	i = 0
	m = 0
	operations = {}
	low = 0
	while i < n:
		while a[i] > b[i]:
			a[i] -= 1
			for j in range(low, n):
				if a[j] < b[j]:
					low = j
					a[j] += 1
					op = tuple((i, j))
					if op in operations:
						operations[op] += 1
					else:
						operations[op] = 1
					break
			m += 1
		i += 1
	print(m)
	for op in operations:
		for _ in range(operations[op]):
			print(f'{op[0] + 1} {op[1] + 1}')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for (x, y) in zip(a, b):
		c.append(x - y)
	if sum(c) == 0:
		if all((i == 0 for i in c)):
			print(0)
		else:
			ans = []
			for i in range(n):
				if c[i] < 0:
					for (second, x) in enumerate(c, 1):
						if x > 0:
							for _ in range(min(x, abs(c[i]))):
								c[second - 1] -= 1
								c[i] += 1
								ans.append((second, i + 1))
						if c[i] == 0:
							break
				elif c[i] > 0:
					for (second, x) in enumerate(c, 1):
						if x < 0:
							for _ in range(min(x, abs(c[i]))):
								c[second - 1] += 1
								c[i] -= 1
								ans.append((i + 1, second))
						if c[i] == 0:
							break
			print(len(ans))
			for (x, y) in ans:
				print(x, y)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	plus = []
	minus = []
	for i in range(n):
		if a[i] < b[i]:
			plus += [i + 1] * (b[i] - a[i])
		elif a[i] > b[i]:
			minus += [i + 1] * (a[i] - b[i])
	l = len(plus)
	print(l)
	for i in range(l):
		print(minus[i], plus[i])


def func(A, B):
	if len(A) != len(B):
		return [-1]
	if sum(A) != sum(B):
		return [-1]
	isq = []
	dsq = []
	for i in range(len(A)):
		if A[i] > B[i]:
			for tm in range(A[i] - B[i]):
				isq.append(i + 1)
		elif A[i] < B[i]:
			for tm in range(B[i] - A[i]):
				dsq.append(i + 1)
	return [isq, dsq]
for t in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = func(A, B)
	if ans[0] == -1:
		print(-1)
	else:
		(isq, dsq) = (ans[0], ans[1])
		print(len(isq))
		for i in range(len(isq)):
			print(isq[i], dsq[i])


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		moves = []
		for i in range(len(a)):
			for j in range(len(a)):
				if a[i] != b[i] and a[j] != b[j]:
					if a[i] < b[i] and a[j] > b[j]:
						for x in range(min(abs(a[i] - b[i]), abs(a[j] - b[j]))):
							moves.append([j + 1, i + 1])
						(a[i], a[j]) = (a[i] + min(abs(a[i] - b[i]), abs(a[j] - b[j])), a[j] - min(abs(a[i] - b[i]), abs(a[j] - b[j])))
					elif a[i] > b[i] and a[j] < b[j]:
						for x in range(min(abs(a[i] - b[i]), abs(a[j] - b[j]))):
							moves.append([i + 1, j + 1])
						(a[i], a[j]) = (a[i] - min(abs(a[i] - b[i]), abs(a[j] - b[j])), a[j] + min(abs(a[i] - b[i]), abs(a[j] - b[j])))
		print(len(moves))
		for i in moves:
			print(' '.join(list(map(str, i))))


t = int(input())
for _ in range(t):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	plus = []
	minus = []
	for i in range(n):
		if arr1[i] > arr2[i]:
			for j in range(arr1[i] - arr2[i]):
				plus.append(i + 1)
		if arr1[i] < arr2[i]:
			for j in range(arr2[i] - arr1[i]):
				minus.append(i + 1)
	if len(plus) != len(minus):
		print(-1)
	else:
		l = len(plus)
		print(l)
		for i in range(l):
			print(plus[i], minus[i])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	la = list(map(int, input().split()))
	lb = list(map(int, input().split()))
	a = []
	b = []
	for i in range(n):
		if la[i] < lb[i]:
			aa = [i + 1 for _ in range(lb[i] - la[i])]
			a += aa
		else:
			bb = [i + 1 for _ in range(la[i] - lb[i])]
			b += bb
	if len(a) == len(b):
		print(len(b))
		for i in range(len(b)):
			print(b[i], a[i])
	else:
		print(-1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	c = 0
	sum = 0
	ai = list()
	aj = list()
	for i in range(n):
		c = b[i] - a[i]
		while c > 0:
			aj.append(i)
			c -= 1
		while c < 0:
			ai.append(i)
			c += 1
	if len(ai) != len(aj):
		print(-1)
		continue
	print(len(ai))
	for i in range(len(ai)):
		print(ai[i] + 1, end=' ')
		print(aj[i] + 1)


from sys import stdin
input = stdin.readline

def answer():
	(add, sub) = ([], [])
	val = 0
	for i in range(n):
		if a[i] - b[i] < 0:
			add.append(i)
		if a[i] - b[i] > 0:
			sub.append(i)
		val += a[i] - b[i]
	if val:
		print(-1)
		return
	(i, j) = (0, 0)
	(x, y) = (len(add), len(sub))
	opp = []
	while i < y and j < x:
		while a[add[j]] != b[add[j]] and a[sub[i]] != b[sub[i]]:
			a[add[j]] += 1
			a[sub[i]] -= 1
			opp.append([sub[i] + 1, add[j] + 1])
		if a[add[j]] == b[add[j]]:
			j += 1
		if a[sub[i]] == b[sub[i]]:
			i += 1
	print(len(opp))
	for x in opp:
		print(*x)
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	answer()


t = int(input())
for g in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	i = 0
	j = 0
	if sum(l) != sum(m):
		print(-1)
	else:
		x = j
		a = []
		b = []
		while 1:
			x = j
			y = i
			for p in range(i, n):
				if m[p] > l[p]:
					i = p
					break
			for q in range(j, n):
				if l[q] > m[q]:
					j = q
					break
			if x == j and l[j] == m[j]:
				break
			l[i] += 1
			l[j] -= 1
			a.append(j + 1)
			b.append(i + 1)
		print(len(a))
		for i in range(len(a)):
			print(a[i], b[i])


def solve(a, b):
	if a == b:
		print(0)
		return
	t = [i - j for (i, j) in zip(a, b)]
	if sum(t) != 0:
		print(-1)
		return
	d = {}
	op = 0
	for (index, i) in enumerate(t):
		if i != 0:
			d[index] = i
		if i > 0:
			op += i
	print(op)
	n = len(d)
	ic = False
	jc = False
	while list(d.values()) != [0] * n:
		if ic is True and jc is True:
			print(i + 1, j + 1)
		ic = False
		jc = False
		for index in d.keys():
			if d[index] == 0:
				continue
			if ic is True and jc is True:
				break
			if jc is False and d[index] < 0:
				j = index
				d[j] += 1
				jc = True
			elif ic is False and d[index] > 0:
				i = index
				d[i] -= 1
				ic = True
	print(i + 1, j + 1)
t = int(input())
for _ in range(t):
	s = int(input())
	a = [int(c) for c in input().split()]
	b = [int(c) for c in input().split()]
	if len(a) != len(b) != s:
		break
	solve(a, b)


import sys, os.path
from collections import *
from heapq import *
from copy import *
mod = 10 ** 9 + 7
read = lambda : map(int, input().split())
inf = float('inf')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	a = list(read())
	b = list(read())
	if sum(a) != sum(b):
		print(-1)
	else:
		t = []
		for i in range(n):
			t.append(a[i] - b[i])
		pair = []
		for i in range(n):
			if t[i] != 0:
				val = t[i]
				if val > 0:
					j = i + 1
					while val != 0:
						if t[j] < 0:
							t[j] += 1
							pair.append((i + 1, j + 1))
							val -= 1
						else:
							j += 1
				else:
					j = i + 1
					while val != 0:
						if t[j] > 0:
							t[j] -= 1
							pair.append((j + 1, i + 1))
							val += 1
						else:
							j += 1
		print(len(pair))
		for i in pair:
			print(*i)


def solve(n, a, b):
	(l, m) = ([], [])
	for i in range(n):
		if a[i] > b[i]:
			for j in range(a[i] - b[i]):
				l.append(i)
		elif a[i] < b[i]:
			for j in range(b[i] - a[i]):
				m.append(i)
	if len(l) == len(m):
		print(len(l))
		if not len(l) == 0:
			for i in range(len(l)):
				print(l[i] + 1, m[i] + 1)
		return 0
	print(-1)
	return -1
t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, a, b)


for a0 in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	add = []
	sub = []
	for i in range(n):
		if a[i] > b[i]:
			for j in range(a[i] - b[i]):
				add.append(i + 1)
		elif a[i] < b[i]:
			for j in range(b[i] - a[i]):
				sub.append(i + 1)
	if len(add) == len(sub):
		print(len(add))
		for i in range(len(add)):
			print(add[i], sub[i])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = []
	flag = False
	for i in range(n):
		need = b[i] - a[i]
		for j in range(i + 1, n):
			have = b[j] - a[j]
			can = min(abs(have), abs(need))
			if have > 0 and need < 0:
				a[j] += can
				need += can
				while can > 0:
					ans.append((i + 1, j + 1))
					can -= 1
			elif have < 0 and need > 0:
				a[j] -= can
				need -= can
				while can > 0:
					ans.append((j + 1, i + 1))
					can -= 1
		if need != 0:
			flag = True
			break
	if flag == True:
		print('-1')
	else:
		print(len(ans))
		for i in ans:
			print(*i)


def inputi():
	return int(input())

def inputli():
	return list(map(int, input().split(' ')))

def inputls():
	return list(map(str, input().split(' ')))

def print_list(lista):
	s = ''
	for i in lista[:-1]:
		s += str(i) + ' '
	s += str(lista[-1])
	return s

def solve(m, a, b):
	negatives = {}
	positives = {}
	zeros = {}
	suma = 0
	for i in range(m):
		diff = b[i] - a[i]
		suma += diff
		if diff < 0:
			negatives[i] = diff
		elif diff == 0:
			zeros[i] = 0
		else:
			positives[i] = diff
	if suma != 0:
		return (None, False)
	id_x = 0
	ans = []
	lista_p = list(positives.keys())
	for id_n in negatives.keys():
		while negatives[id_n] < 0:
			if positives[lista_p[id_x]] > 0:
				positives[lista_p[id_x]] -= 1
				negatives[id_n] += 1
				ans.append([lista_p[id_x] + 1, id_n + 1])
			else:
				id_x += 1
	return (ans, True)
n = inputi()
for i in range(n):
	m = inputi()
	a = inputli()
	b = inputli()
	(ans, band) = solve(m, a, b)
	if band:
		print(len(ans))
		for ga in ans:
			print(ga[1], ga[0])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	minus = []
	sum = []
	for i in range(n):
		for _ in range(a[i] - b[i]):
			minus.append(i)
		for _ in range(b[i] - a[i]):
			sum.append(i)
	if len(minus) == len(sum):
		print(len(minus))
		for i in range(len(minus)):
			print(minus[i] + 1, sum[i] + 1)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	suma = sum(a)
	sumb = sum(b)
	if sumb != suma:
		print('-1')
	else:
		j = []
		k = []
		for i in range(n):
			if a[i] == b[i]:
				continue
			elif a[i] < b[i]:
				temp = abs(b[i] - a[i])
				while temp != 0:
					j.append(i)
					temp -= 1
			else:
				temp = abs(b[i] - a[i])
				while temp != 0:
					k.append(i)
					temp -= 1
		if len(j) == 0 and len(k) == 0:
			print('0')
		else:
			print(len(j))
			for i in range(len(j)):
				print(k[i] + 1, j[i] + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if sum(a) != sum(b):
		print('-1')
		continue
	for i in range(n):
		a[i] -= b[i]
	p = sum((a[i] for i in range(n) if a[i] > 0))
	print(p)
	(i, j) = (0, 0)
	while p:
		while i < n and a[i] <= 0:
			i += 1
		while j < n and a[j] >= 0:
			j += 1
		a[i] -= 1
		a[j] += 1
		print(i + 1, j + 1)
		p -= 1


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dec = 0
	inc = 0
	decrease = []
	increase = []
	for i in range(n):
		if a[i] >= b[i]:
			x = a[i] - b[i]
			dec += x
			for j in range(x):
				decrease.append(i + 1)
		elif a[i] <= b[i]:
			x = b[i] - a[i]
			inc += x
			for j in range(x):
				increase.append(i + 1)
	arr = []
	if dec != inc:
		print(-1)
	elif dec == 0:
		print(0)
	else:
		print(len(increase))
		for i in range(len(increase)):
			print(str(decrease[i]) + ' ' + str(increase[i]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	has_tambah = []
	has_kurang = []
	for i in range(n):
		if a[i] < b[i]:
			has_tambah += [i + 1] * (b[i] - a[i])
		elif a[i] > b[i]:
			has_kurang += [i + 1] * (a[i] - b[i])
	if len(has_tambah) != len(has_kurang):
		print(-1)
	else:
		print(len(has_tambah))
		for i in range(len(has_tambah)):
			print(has_kurang[i], has_tambah[i])


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		return
	m = 0
	for i in range(n):
		if a[i] > b[i]:
			m += a[i] - b[i]
	print(m)
	(i, j) = (0, 0)
	while True:
		while i < n and a[i] <= b[i]:
			i += 1
		while j < n and a[j] >= b[j]:
			j += 1
		if i == n or j == n:
			break
		while a[i] > b[i] and a[j] < b[j]:
			a[i] -= 1
			a[j] += 1
			print(i + 1, j + 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()))
	(add, sub) = (0, 0)
	(x, y) = ([], [])
	for i in range(n):
		if a[i] < b[i]:
			for j in range(b[i] - a[i]):
				x.append(i)
		elif a[i] > b[i]:
			for j in range(a[i] - b[i]):
				y.append(i)
	if len(x) != len(y):
		print(-1)
	else:
		print(len(x))
		for (i, j) in zip(y, x):
			print(i + 1, j + 1)


t = int(input())
for k in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	if sum(a) != sum(b):
		print(-1)
	else:
		s = sum(list(map(lambda x, y: abs(x - y), a, b)))
		print(s // 2)
		for i in range(n):
			if a[i] != b[i]:
				if a[i] > b[i]:
					for j in range(i + 1, n):
						while a[j] < b[j]:
							print(i + 1, j + 1)
							a[j] += 1
							a[i] -= 1
							if a[i] == b[i]:
								break
						if a[i] == b[i]:
							break
				else:
					for j in range(i + 1, n):
						while a[j] > b[j]:
							print(j + 1, i + 1)
							a[j] -= 1
							a[i] += 1
							if a[i] == b[i]:
								break
						if a[i] == b[i]:
							break


cases = int(input())
for idx in range(cases):
	n = int(input())
	lista = list(map(int, input().split()))
	listb = list(map(int, input().split()))
	if sum(lista) != sum(listb):
		print(-1)
	elif lista == listb:
		print(0)
	else:
		tuples = []
		count = 0
		for idx in range(n):
			jdx = 0
			while jdx < n:
				while lista[jdx] < listb[jdx] and lista[idx] > listb[idx]:
					lista[idx] -= 1
					lista[jdx] += 1
					(i, j) = (idx + 1, jdx + 1)
					tuples.append((i, j))
					count += 1
				jdx += 1
				if lista[idx] == listb[idx]:
					jdx = n
		print(count)
		for (i, j) in tuples:
			print(i, j)


def main():
	from sys import stdin, setrecursionlimit
	from math import gcd
	from random import randint, choice, shuffle
	from itertools import combinations, product
	from functools import lru_cache
	from re import search, finditer
	input = stdin.readline
	for _ in range(int(input())):
		n = int(input())
		(*a,) = map(int, input().split())
		(*b,) = map(int, input().split())
		if sum(a) != sum(b):
			print(-1)
		else:
			ans = []
			for i in range(n):
				for j in range(i + 1, n):
					while a[i] < b[i] and a[j] > b[j]:
						ans.append((j + 1, i + 1))
						a[j] -= 1
						a[i] += 1
					while a[i] > b[i] and a[j] < b[j]:
						ans.append((i + 1, j + 1))
						a[i] -= 1
						a[j] += 1
			print(len(ans))
			for i in ans:
				print(*i)
main()


n = int(input())
for i in range(n):
	t = int(input())
	a = map(int, input().split())
	b = map(int, input().split())
	a = list(a)
	b = list(b)
	A = []
	B = []
	if sum(a) == sum(b):
		for i in range(len(a)):
			b[i] = int(b[i])
			a[i] = int(a[i])
			if b[i] > a[i]:
				k = b[i] - a[i]
				while k > 0:
					A.append(i)
					k = k - 1
			if b[i] < a[i]:
				c = a[i] - b[i]
				while c > 0:
					B.append(i)
					c = c - 1
		print(len(A))
		for j in range(len(A)):
			print(B[j] + 1, A[j] + 1, end='\n')
	else:
		print(-1)


cases = int(input())
for idx in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	elif a == b:
		print(0)
	else:
		tuples = []
		count = 0
		for i in range(n):
			if a[i] == b[i]:
				continue
			if a[i] > b[i]:
				while a[i] > b[i]:
					diff1 = a[i] - b[i]
					for j in range(n):
						if i == j:
							continue
						if a[j] < b[j]:
							diff2 = b[j] - a[j]
							diffmin = min(diff1, diff2)
							a[i] -= diffmin
							a[j] += diffmin
							diff1 -= diffmin
							count += diffmin
							for k in range(diffmin):
								tuples.append((i + 1, j + 1))
		print(count)
		for (i, j) in tuples:
			print(i, j)


for _ in range(int(input())):
	n = int(input())
	arr = [int(w) for w in input().split(' ')]
	b = [int(w) for w in input().split(' ')]
	if sum(arr) != sum(b):
		print(-1)
	else:
		ans = 0
		res = []
		for i in range(n):
			if arr[i] == b[i]:
				pass
			elif arr[i] > b[i]:
				avail = arr[i] - b[i]
				arr[i] = b[i]
				for j in range(n):
					if avail == 0:
						break
					while arr[j] < b[j]:
						ans = ans + 1
						avail = avail - 1
						res.append([i + 1, j + 1])
						arr[j] = arr[j] + 1
						if avail == 0:
							break
		print(ans)
		for item in res:
			print(item[0], item[1])


def sex(a, b):
	if sum(a) != sum(b):
		print(-1)
		return
	if len(a) != len(b):
		print(-1)
		return
	result = ''
	plus = []
	minus = []
	for i in range(len(a)):
		if a[i] < b[i]:
			for _ in range(b[i] - a[i]):
				plus.append(i)
		else:
			for _ in range(a[i] - b[i]):
				minus.append(i)
	m = len(plus)
	print(m)
	for i in range(m):
		print(minus[i] + 1, plus[i] + 1)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sex(a, b)


t = int(input())
for k in range(t):
	c = 0
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		c = 0
	else:
		arri = 0
		arrj = 0
		c = 1
		sumi = 0
		arr = [0] * n
		ab = []
		for i in range(n):
			arr[i] = a[i] - b[i]
		ab = arr
		for i in range(n):
			if arr[i] > 0:
				sumi += arr[i]
		print(sumi)
		i = 0
		y = 0
		for i in range(n):
			for j in range(n):
				while arr[i] > 0 and arr[j] < 0:
					print(i + 1, j + 1)
					arr[i] -= 1
					arr[j] += 1
				while arr[i] < 0 and arr[j] > 0:
					print(j + 1, i + 1)
					arr[i] += 1
					arr[j] -= 1
	if c == 0:
		print(-1)


res = []
for _ in range(int(input())):
	res = []
	_res = []
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	for i in range(n):
		if a[i] > b[i]:
			res += [i + 1] * -(b[i] - a[i])
	for i in range(n):
		if a[i] < b[i]:
			_res += [i + 1] * -(a[i] - b[i])
	n = len(res)
	if n != len(_res):
		print(-1)
		continue
	print(n)
	for i in range(n):
		print(res[i], _res[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	diffs = []
	for i in range(n):
		diffs.append(a[i] - b[i])
	if sum(diffs) != 0:
		print('-1')
		continue
	index_one = []
	index_two = []
	for i in range(n):
		if diffs[i] < 0:
			num = diffs[i]
			while num < 0:
				index_two.append(i + 1)
				num = num + 1
		elif diffs[i] > 0:
			num = diffs[i]
			while num > 0:
				index_one.append(i + 1)
				num = num - 1
	print(len(index_one))
	for i in range(len(index_one)):
		print(index_one[i], index_two[i])


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	for i in range(n):
		s += b[i] - a[i]
	if a == b:
		print(0)
		return
	else:
		x = []
		y = []
		for i in range(n):
			if b[i] > a[i]:
				x.append([i, b[i] - a[i]])
			elif a[i] > b[i]:
				y.append([i, a[i] - b[i]])
		k = []
		l = []
		for i in x:
			for j in range(i[1]):
				k.append(i[0] + 1)
		for i in y:
			for j in range(i[1]):
				l.append(i[0] + 1)
		if len(k) != len(l):
			print(-1)
			return
		print(len(k))
		for i in range(len(k)):
			print(l[i], k[i])
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if sum(a) != sum(b):
		print(-1)
	else:
		avg = sum(a) / n
		(i, j) = (0, 0)
		ans = []
		while i < n and j < n:
			while i < n and a[i] <= b[i]:
				i += 1
			while j < n and a[j] >= b[j]:
				j += 1
			if i < n:
				a[i] -= 1
				a[j] += 1
				ans.append((i + 1, j + 1))
		print(len(ans))
		for i in ans:
			print(*i)


for _ in range(int(input())):
	n = int(input())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	pos = []
	neg = []
	if sum(arr1) != sum(arr2):
		print(-1)
	else:
		for i in range(n):
			if arr2[i] - arr1[i] > 0:
				for j in range(arr2[i] - arr1[i]):
					pos.append(i + 1)
			elif arr2[i] - arr1[i] < 0:
				for j in range(arr1[i] - arr2[i]):
					neg.append(i + 1)
		print(len(pos))
		for i in range(len(pos)):
			print(neg[i], pos[i])


import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	dif = []
	for i in range(n):
		dif.append(b[i] - a[i])
	if sum(dif) != 0:
		print(-1)
		continue
	neg = []
	pos = []
	for i in range(n):
		while dif[i] > 0:
			pos.append(i)
			dif[i] -= 1
		while dif[i] < 0:
			neg.append(i)
			dif[i] += 1
	print(len(pos))
	for i in range(len(pos)):
		print(neg[i] + 1, pos[i] + 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		temp1 = []
		temp2 = []
		for i in range(n):
			if a[i] > b[i]:
				temp = [i + 1 for _ in range(abs(a[i] - b[i]))]
				temp1.extend(temp)
			elif b[i] > a[i]:
				temp = [i + 1 for _ in range(abs(a[i] - b[i]))]
				temp2.extend(temp)
		nn = len(temp1)
		print(nn)
		for i in range(nn):
			print(*[temp1[i], temp2[i]])


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
for _ in range(ii1()):
	n = ii1()
	a = iia()
	b = iia()
	summ = 0
	for (ai, bi) in zip(a, b):
		summ += ai - bi
	if summ == 0:
		pos = []
		neg = []
		for i in range(n):
			ai = a[i]
			bi = b[i]
			if ai > bi:
				for j in range(ai - bi):
					pos.append(i)
			else:
				for j in range(bi - ai):
					neg.append(i)
		print(len(pos))
		for (pi, ni) in zip(pos, neg):
			print(pi + 1, ni + 1)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	brr = [int(i) for i in input().split(' ')]
	a = b = 0
	inde_a = {}
	inde_b = {}
	inde = 0
	for (i, j) in zip(arr, brr):
		if i > j:
			a += i - j
			inde_a[inde] = i - j
		elif j > i:
			b += j - i
			inde_b[inde] = j - i
		inde += 1
	if a != b:
		print(-1)
		continue
	print(a)
	ke_a = list(inde_a.keys())
	ke_b = list(inde_b.keys())
	ke_diffa = 0
	ke_diffb = 0
	diffa = -1
	diffb = -1
	while a > 0:
		if ke_diffa == 0:
			diffa += 1
			ke_diffa = inde_a[ke_a[diffa]]
		if ke_diffb == 0:
			diffb += 1
			ke_diffb = inde_b[ke_b[diffb]]
		print(ke_a[diffa] + 1, ke_b[diffb] + 1)
		ke_diffa -= 1
		ke_diffb -= 1
		a -= 1


test_cases = int(input())
for t in range(test_cases):
	n = int(input())
	a_str = input().split(' ')
	a = [int(_) for _ in a_str]
	b_str = input().split(' ')
	b = [int(_) for _ in b_str]
	if a == b:
		print(0)
		continue
	sum_a = sum(a)
	sum_b = sum(b)
	if sum_a != sum_b:
		print(-1)
		continue
	combinations = []
	for i in range(n):
		while a[i] < b[i]:
			for j in range(i + 1, n):
				if a[j] > b[j]:
					a[i] += 1
					a[j] -= 1
					combinations.append((j + 1, i + 1))
					break
		while a[i] > b[i]:
			for j in range(i + 1, n):
				if a[j] < b[j]:
					a[i] -= 1
					a[j] += 1
					combinations.append((i + 1, j + 1))
					break
	print(len(combinations))
	for el in combinations:
		print(el[0], el[1])


for t in range(int(input())):
	n = int(input())
	A = [int(X) for X in input().split()]
	B = [int(X) for X in input().split()]
	list = []
	L = []
	(pluscount, minuscount) = (0, 0)
	(pluslist, minuslist) = ([], [])
	for i in range(n):
		if A[i] - B[i] > 0:
			minuscount += A[i] - B[i]
			minuslist.append([i + 1, A[i] - B[i]])
		elif A[i] - B[i] < 0:
			pluscount += B[i] - A[i]
			pluslist.append([i + 1, B[i] - A[i]])
	if pluscount == minuscount:
		print(pluscount)
		for X in pluslist:
			for i in range(X[1]):
				list.append(X[0])
		for Y in minuslist:
			for i in range(Y[1]):
				L.append(Y[0])
		for i in range(pluscount):
			print(L[i], list[i])
	else:
		print(-1)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) == sum(b):
		if a == b:
			print(0)
		else:
			(neg, pos) = ([], [])
			for i in range(n):
				if a[i] < b[i]:
					temp = [i + 1] * (b[i] - a[i])
					pos.extend(temp)
				else:
					temp = [i + 1] * (a[i] - b[i])
					neg.extend(temp)
			ll = len(pos)
			print(ll)
			for i in range(ll):
				print(neg[i], pos[i])
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		il = []
		dl = []
		for j in range(n):
			if a[j] > b[j]:
				for k in range(a[j] - b[j]):
					dl.append(j + 1)
			if a[j] < b[j]:
				for k in range(-a[j] + b[j]):
					il.append(j + 1)
		print(len(dl))
		for j in range(len(dl)):
			print(dl[j], il[j])


for iii in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	w = list(map(int, input().split()))
	if sum(q) != sum(w):
		print(-1)
	else:
		flag = 0
		for i in range(n):
			if q[i] != w[i]:
				break
		else:
			flag = 1
			print(0)
		if flag == 0:
			qq = []
			for i in range(n):
				if q[i] == w[i]:
					continue
				if q[i] < w[i]:
					while q[i] < w[i]:
						j = i + 1
						while q[i] < w[i]:
							if q[j] > w[j]:
								while q[j] > w[j] and q[i] < w[i]:
									qq.append([j + 1, i + 1])
									q[j] -= 1
									q[i] += 1
							j += 1
				if q[i] > w[i]:
					while q[i] > w[i]:
						j = i + 1
						while q[i] > w[i]:
							if q[j] < w[j]:
								while q[j] < w[j] and q[i] > w[i]:
									qq.append([i + 1, j + 1])
									q[j] += 1
									q[i] -= 1
							if j < n:
								j += 1
			print(len(qq))
			for i in qq:
				print(i[0], i[1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	diff = 0
	for i in range(n):
		if a[i] > b[i]:
			diff += a[i] - b[i]
		else:
			diff -= b[i] - a[i]
	if diff != 0:
		print(-1)
		continue
	left = []
	right = []
	for i in range(n):
		if a[i] > b[i]:
			left.extend([i + 1] * (a[i] - b[i]))
		elif a[i] < b[i]:
			right.extend([i + 1] * (b[i] - a[i]))
	print(len(left))
	for i in range(len(left)):
		print(left[i], right[i])


t = int(input())
for task in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = sum(a)
	sb = sum(b)
	if sa == sb:
		moves = []
		curLess = -1
		curMore = -1
		while curLess < n and curMore < n:
			while curLess == -1 or (curLess < n and a[curLess] >= b[curLess]):
				curLess += 1
			while curMore == -1 or (curMore < n and a[curMore] <= b[curMore]):
				curMore += 1
			if curLess < n and curMore < n:
				moves.append(str(curMore + 1) + ' ' + str(curLess + 1))
				a[curLess] += 1
				a[curMore] -= 1
		print(len(moves))
		for m in moves:
			print(m)
	else:
		print(-1)


for tests in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	neg = []
	count = 0
	count1 = 0
	pos = []
	for i in range(n):
		if a[i] > b[i]:
			neg.append([b[i] - a[i], i + 1])
			count1 = count1 + b[i] - a[i]
		elif a[i] < b[i]:
			pos.append([b[i] - a[i], i + 1])
			count = count + b[i] - a[i]
	i = 0
	if count + count1 == 0:
		print(count)
		while len(neg) != 0 and len(pos) != 0:
			if neg[i][0] == 0:
				del neg[i]
			if pos[i][0] == 0:
				del pos[i]
			if len(neg) == 0 or len(pos) == 0:
				break
			print(neg[i][1], pos[i][1])
			neg[i][0] += 1
			pos[i][0] -= 1
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	r = [a[x] - b[x] for x in range(n)]
	if sum(r) != 0:
		print(-1)
		continue
	minuses = (x for x in range(n) if r[x] < 0)
	pluses = (x for x in range(n) if r[x] > 0)
	print(sum([x for x in r if x > 0]))
	minuse = next(minuses, None)
	pluse = next(pluses, None)
	while minuse is not None and pluse is not None:
		r[minuse] += 1
		r[pluse] -= 1
		print(pluse + 1, minuse + 1)
		if r[minuse] >= 0:
			minuse = next(minuses, None)
		if r[pluse] <= 0:
			pluse = next(pluses, None)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp = lambda : list(map(int, sys.stdin.readline().rstrip('\r\n').split()))
mod = 10 ** 9 + 7
Mod = 998244353
INF = float('inf')
import math
from bisect import *
from heapq import *
from collections import defaultdict as dd
from collections import OrderedDict as odict
from collections import Counter as cc
from collections import deque
from itertools import groupby
sys.setrecursionlimit(20 * 20 * 20 * 20 + 10)

def solve():
	n = takein()
	a = takeiar()
	b = takeiar()
	pos = []
	neg = []
	if a == b:
		print(0)
		return
	for i in range(n):
		if a[i] == b[i]:
			continue
		elif a[i] > b[i]:
			for j in range(a[i] - b[i]):
				neg.append(i)
		else:
			for j in range(b[i] - a[i]):
				pos.append(i)
	if len(pos) != len(neg):
		print(-1)
	else:
		print(len(pos))
		for i in range(len(pos)):
			print(neg[i] + 1, pos[i] + 1)
	return

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = takein()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def takein():
	return int(sys.stdin.readline().rstrip('\r\n'))

def takesr():
	return sys.stdin.readline().rstrip('\r\n')

def takeiar():
	return list(map(int, sys.stdin.readline().rstrip('\r\n').split()))

def takesar():
	return list(map(str, sys.stdin.readline().rstrip('\r\n').split()))

def takeivr():
	return map(int, sys.stdin.readline().rstrip('\r\n').split())

def takesvr():
	return map(str, sys.stdin.readline().rstrip('\r\n').split())

def ispalindrome(s):
	return s == s[::-1]

def invert(bit_s):
	temp = int(bit_s, 2)
	inverse_s = temp ^ 2 ** (len(bit_s) + 1) - 1
	rslt = bin(inverse_s)[3:]
	return str(rslt)

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p ** 2, n + 1, p):
				prime[i] = False
		p = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		(p, q) = ([], [])
		for i in range(n):
			if a[i] < b[i]:
				q += [i + 1] * abs(a[i] - b[i])
			elif b[i] < a[i]:
				p += [i + 1] * abs(a[i] - b[i])
		print(len(p))
		for (i, j) in zip(p, q):
			print(i, j)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print(0)
	else:
		x = [int(b[i]) - int(a[i]) for i in range(n)]
		q = []
		w = []
		if sum(x) == 0:
			for i in range(n):
				if x[i] < 0:
					q += [i] * abs(x[i])
				elif x[i] > 0:
					w += [i] * x[i]
			print(len(q))
			for qq in range(len(q)):
				print(q[qq] + 1, w[qq] + 1)
		else:
			print(-1)


n = int(input())
for i in range(n):
	k = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sm1 = 0
	sm2 = 0
	m = [0 for i in range(k)]
	p = [0 for i in range(k)]
	for i in range(k):
		sm1 += a[i]
		sm2 += b[i]
		if a[i] < b[i]:
			p[i] += b[i] - a[i]
		else:
			m[i] += a[i] - b[i]
	if sm1 != sm2 or sum(m) != sum(p):
		print(-1)
	else:
		print(sum(p))
		j = 0
		for i in range(k):
			if m[i] != 0:
				while m[i] != 0:
					while p[j] == 0:
						j += 1
					while p[j] != 0 and m[i] != 0:
						print(i + 1, j + 1)
						p[j] -= 1
						m[i] -= 1


from sys import *
input = lambda : stdin.readline()
int_arr = lambda : list(map(int, stdin.readline().strip().split()))
str_arr = lambda : list(map(str, stdin.readline().split()))
get_str = lambda : map(str, stdin.readline().strip().split())
get_int = lambda : map(int, stdin.readline().strip().split())
get_float = lambda : map(float, stdin.readline().strip().split())
mod = 1000000007
setrecursionlimit(1000)
for _ in range(int(input())):
	n = int(input())
	a = int_arr()
	b = int_arr()
	lst = []
	if sum(a) == sum(b):
		for i in range(n):
			for j in range(i + 1, n):
				if a[i] > b[i]:
					while a[i] > b[i]:
						if a[j] < b[j]:
							a[j] += 1
							a[i] -= 1
							lst.append([i + 1, j + 1])
						else:
							break
				elif a[i] < b[i]:
					while a[i] < b[i]:
						if a[j] > b[j]:
							a[j] -= 1
							a[i] += 1
							lst.append([j + 1, i + 1])
						else:
							break
		if a == b:
			print(len(lst))
			for i in lst:
				print(*i)
		else:
			print(-1)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		subtr = []
		add = []
		for i in range(len(a)):
			dif = a[i] - b[i]
			if dif > 0:
				for j in range(dif):
					subtr.append(i + 1)
			elif dif < 0:
				for j in range(abs(dif)):
					add.append(i + 1)
		length = len(subtr)
		print(length)
		for i in range(length):
			print(subtr[i], add[i])


t = int(input())
for w in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	j = 0
	c = []
	d = []
	for k in range(n):
		res = b[k] - a[k]
		j += res
		if res > 0:
			[d.append(k) for p in range(res)]
		elif res < 0:
			[c.append(k) for p in range(-1 * res)]
	if j != 0:
		print(-1)
	else:
		m = len(c)
		print(m)
		for i in range(m):
			print(c[i] + 1, d[i] + 1)


for idfghjk in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ai = []
	aj = []
	for i in range(n):
		if a[i] > b[i]:
			for j in range(a[i] - b[i]):
				ai.append(i)
		if a[i] < b[i]:
			for j in range(b[i] - a[i]):
				aj.append(i)
	if len(ai) == len(aj):
		print(len(ai))
		for i in range(len(ai)):
			print(ai[i] + 1, aj[i] + 1)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	(gets, gives) = ([], [])
	for i in range(n):
		if a[i] > b[i]:
			for _ in range(a[i] - b[i]):
				gets.append(i + 1)
		if a[i] < b[i]:
			for _ in range(b[i] - a[i]):
				gives.append(i + 1)
	print(len(gives))
	for i in range(len(gives)):
		print(gets[i], gives[i])


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, a, b):
	if sum(a) != sum(b):
		print(-1)
		return
	if a == b:
		print(0)
		return
	else:
		d = []
		c = 0
		for i in range(n):
			if a[i] == b[i]:
				c += 1
			if a[i] < b[i]:
				for j in range(n):
					while a[j] > b[j] and a[i] < b[i]:
						d.append([j + 1, i + 1])
						a[j] -= 1
						a[i] += 1
					if a[i] == b[i]:
						c += 1
		print(len(d))
		for i in d:
			print(*i)
for _ in range(int(input())):
	n = int(input())
	a = int_arr()
	b = int_arr()
	solve(n, a, b)


def ans(a, b, n):
	if sum(a) != sum(b):
		print(-1)
		return
	d = {}
	count = 0
	for i in range(len(a)):
		if a[i] < b[i]:
			count += b[i] - a[i]
		if a[i] != b[i]:
			d[i + 1] = b[i] - a[i]
	print(count)
	d1 = {}
	d2 = {}
	for i in d:
		if d[i] < 0:
			d2[i] = d[i]
		else:
			d1[i] = d[i]
	l1 = list(d1.keys())
	l2 = list(d2.keys())
	i = 0
	j = 0
	while i < len(l1) and j < len(l2):
		x = d1[l1[i]]
		y = d2[l2[j]]
		print(str(l2[j]) + ' ' + str(l1[i]))
		d1[l1[i]] -= 1
		d2[l2[j]] += 1
		if d1[l1[i]] == 0:
			i += 1
		if d2[l2[j]] == 0:
			j += 1
	return
m = int(input())
for i in range(m):
	n = int(input())
	arr = input().split()
	a = []
	for i in arr:
		a.append(int(i))
	arr = input().split()
	b = []
	for i in arr:
		b.append(int(i))
	ans(a, b, n)


from sys import stdin, stdout
import sys
import math
import itertools
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)

def main():
	t = int(stdin.readline().strip())
	for j in range(1, t + 1):
		n = int(stdin.readline().strip())
		a = [int(x) for x in stdin.readline().split()]
		b = [int(x) for x in stdin.readline().split()]
		diff = [0] * n
		increase = []
		decrease = []
		for i in range(n):
			diff[i] = a[i] - b[i]
			if diff[i] < 0:
				increase += [i] * -diff[i]
			elif diff[i] > 0:
				decrease += [i] * diff[i]
		if sum(diff) != 0:
			print(-1)
		else:
			print(len(decrease))
			for i in range(len(decrease)):
				print(decrease[i] + 1, increase[i] + 1)
main()


def areEqual(ar1, ar2):
	for i in range(0, len(ar1)):
		if ar1[i] != ar2[i]:
			return False
	return True
test = int(input())
for z in range(0, test):
	n = int(input())
	arr1 = list(map(int, input().split()))[:n]
	arr2 = list(map(int, input().split()))[:n]
	if sum(arr1) != sum(arr2):
		print(-1)
	elif areEqual(arr1, arr2):
		print(0)
	else:
		inc = []
		dec = []
		x = 0
		while x < n:
			if arr1[x] == arr2[x]:
				x += 1
			elif arr1[x] < arr2[x]:
				c = arr2[x] - arr1[x]
				for a in range(0, c):
					inc.append(x + 1)
				x += 1
			else:
				c = arr1[x] - arr2[x]
				for a in range(0, c):
					dec.append(x + 1)
				x += 1
		m = len(inc)
		print(m)
		for j in range(0, m):
			print(dec[j], inc[j])


test = int(input())
for i in range(test):
	long = int(input())
	st = input()
	ed = input()
	st = st.split()
	ed = ed.split()
	ics = []
	dcs = []
	for j in range(long):
		ed[j] = int(ed[j])
		st[j] = int(st[j])
		if ed[j] > st[j]:
			for h in range(ed[j] - st[j]):
				ics.append(j + 1)
		elif ed[j] < st[j]:
			for h in range(st[j] - ed[j]):
				dcs.append(j + 1)
	if len(ics) == len(dcs) == 0:
		print('0')
	elif len(ics) != len(dcs):
		print('-1')
	else:
		print(len(ics))
		for j in range(len(ics)):
			print('%i %i' % (dcs[j], ics[j]))


def solve():
	n = int(input())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	if sum(a) != sum(b):
		print(-1)
		return
	if a == b:
		print(0)
		return
	c = [0] * n
	d = [0] * n
	k = 0
	for i in range(n):
		c[i] = b[i] - a[i]
		if c[i] > 0:
			k += c[i]
			d[i] = 1
		elif c[i] < 0:
			d[i] = -1
	print(k)
	for i in range(k):
		x = d.index(-1)
		y = d.index(1)
		print(x + 1, y + 1)
		c[x] += 1
		c[y] -= 1
		if c[x] == 0:
			d[x] = 0
		if c[y] == 0:
			d[y] = 0
t = int(input())
answer = []
for tt in range(t):
	solve()


for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = [x - y for (x, y) in zip(a, b)]
	an = []
	ap = []
	for (v, t) in enumerate(d, 1):
		if t > 0:
			ap += [v] * t
		else:
			an += [v] * -t
	if len(ap) != len(an):
		print(-1)
	else:
		print(len(ap))
		for x in zip(ap, an):
			print(*x)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = input().split()
	a = [int(x) for x in a]
	b = input().split()
	b = [int(x) for x in b]
	ans = []
	for i in range(0, n):
		b[i] = a[i] - b[i]
	if sum(b) != 0:
		print(-1)
	else:
		x = 0
		y = 0
		while x < n and y < n:
			while x < n and b[x] <= 0:
				x += 1
			while y < n and b[y] >= 0:
				y += 1
			if x < n and y < n:
				b[x] -= 1
				b[y] += 1
				ans.append((x + 1, y + 1))
		print(len(ans))
		for xi in ans:
			print(str(xi[0]) + ' ' + str(xi[1]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		c.append(b[i] - a[i])
	if sum(c) != 0:
		print(-1)
	else:
		s = 0
		for i in range(len(c)):
			if c[i] > 0:
				s += c[i]
		d = [[0, 0] for i in range(s)]
		p = 0
		n = 0
		for i in range(len(c)):
			if c[i] > 0:
				for x in range(c[i]):
					d[p][0] = i + 1
					p += 1
			else:
				for x in range(abs(c[i])):
					d[n][1] = i + 1
					n += 1
		print(s)
		for i in d:
			print(i[1], i[0])


t = int(input())
for no in range(t):
	n = int(input())
	l = []
	count = 0
	a = [int(num) for num in input().split(' ', n - 1)]
	b = [int(num) for num in input().split(' ', n - 1)]
	if sum(a) != sum(b):
		print(-1)
	else:
		for i in range(n):
			for j in range(n + 1):
				while a[i] > b[i] and a[j] < b[j]:
					a[i] -= 1
					a[j] += 1
					count += 1
					l.append((i + 1, j + 1))
				while a[i] < b[i] and a[j] > b[j]:
					a[i] += 1
					a[j] -= 1
					count += 1
					l.append((1 + j, 1 + i))
		print(count)
		for elem in l:
			print(str(elem[0]) + ' ' + str(elem[1]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	result = []
	up = []
	down = []
	for i in range(n):
		if a[i] > b[i]:
			for j in range(a[i] - b[i]):
				up.append(i + 1)
		elif a[i] < b[i]:
			for j in range(b[i] - a[i]):
				down.append(i + 1)
	l = len(up)
	print(l)
	for i in range(l):
		print(up[i], down[i])


for _ in range(int(input())):
	n = int(input())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	retrivei = []
	retrivej = []
	count = 0
	arr3 = arr1
	c = len(arr3) - 1
	if sum(arr1) != sum(arr2):
		print(-1)
	else:
		for i in range(c + 1):
			arr3[i] = arr3[i] - arr2[i]
		for a in range(len(arr3)):
			if arr3[a] == 0:
				continue
			elif arr3[a] > 0:
				while arr3[a] != 0:
					arr3[a] = arr3[a] - 1
					retrivei.append(a + 1)
					count += 1
		for b in range(len(arr3)):
			if arr3[b] == 0:
				continue
			elif arr3[b] < 0:
				while arr3[b] != 0:
					arr3[b] = arr3[b] + 1
					retrivej.append(b + 1)
		print(count)
		for d in range(len(retrivei)):
			print(retrivei[d], retrivej[d])


import math
import os
import random
import re
import sys
import operator
t = int(input())
while t:
	t -= 1
	n = int(input())
	lis1 = list(map(int, input().rstrip().split()))
	lis2 = list(map(int, input().rstrip().split()))
	if sum(lis1) != sum(lis2):
		print(-1)
	else:
		L = list(map(operator.sub, lis1, lis2))
		l1 = []
		l2 = []
		L.insert(0, 0)
		for i in range(1, n + 1):
			if L[i] > 0:
				l1 += [i] * L[i]
			elif L[i] < 0:
				l2 += [i] * -L[i]
		nn = len(l1)
		print(nn)
		i = 0
		while i < nn:
			print(l1[i], l2[i])
			i += 1


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		return
	ans = []
	for i in range(n):
		cur_ind = i + 1
		while a[i] > b[i] and cur_ind < n:
			while a[i] > b[i] and a[cur_ind] < b[cur_ind]:
				ans.append((i, cur_ind))
				a[i] -= 1
				a[cur_ind] += 1
			cur_ind += 1
		cur_ind = i + 1
		while a[i] < b[i] and cur_ind < n:
			while a[i] < b[i] and a[cur_ind] > b[cur_ind]:
				ans.append((cur_ind, i))
				a[i] += 1
				a[cur_ind] -= 1
			cur_ind += 1
	print(len(ans))
	for i in ans:
		print(i[0] + 1, i[1] + 1)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	else:
		i = list()
		j = list()
		for m in range(n):
			if a[m] > b[m]:
				i += [m + 1] * (a[m] - b[m])
			elif a[m] < b[m]:
				j += [m + 1] * (b[m] - a[m])
		print(len(i))
		for k in range(len(i)):
			print(i[k], j[k])


for t in range(int(input())):
	n = int(input())
	a12 = list(map(int, input().strip().split()))
	b12 = list(map(int, input().strip().split()))
	da1 = 0
	da2 = 0
	hda = {}
	hdb = {}
	index = 0
	for (i, j) in zip(a12, b12):
		if i > j:
			da1 += i - j
			hda[index] = i - j
		elif i < j:
			da2 += j - i
			hdb[index] = j - i
		index += 1
	if da1 != da2:
		print('-1')
		continue
	print(da1)
	keda = list(hda.keys())
	kedb = list(hdb.keys())
	dka1 = 0
	dkb2 = 0
	p = -1
	y = -1
	while da1 > 0:
		if dka1 == 0:
			p += 1
			dka1 = hda[keda[p]]
		if dkb2 == 0:
			y += 1
			dkb2 = hdb[kedb[y]]
		print(keda[p] + 1, kedb[y] + 1)
		dka1 -= 1
		dkb2 -= 1
		da1 -= 1


import sys
input = sys.stdin.readline

def S():
	return input()

def I():
	return int(S())

def M():
	return map(int, S().split())

def L():
	return list(M())
for _ in range(I()):
	n = I()
	a = L()
	b = L()
	increase = 0
	decrease = 0
	inc = []
	dec = []
	for i in range(n):
		if a[i] < b[i]:
			diff = b[i] - a[i]
			increase += diff
			for j in range(diff):
				inc.append(i + 1)
		else:
			diff = a[i] - b[i]
			decrease += diff
			for j in range(diff):
				dec.append(i + 1)
	if increase != decrease:
		print(-1)
	else:
		print(increase)
		for i in range(increase):
			print(dec[i], inc[i])


cases = int(input())
for idx in range(cases):
	n = int(input())
	lista = list(map(int, input().split()))
	listb = list(map(int, input().split()))
	dec = []
	inc = []
	if sum(lista) != sum(listb):
		print(-1)
	elif lista == listb:
		print(0)
	else:
		for i in range(n):
			if lista[i] > listb[i]:
				for j in range(lista[i] - listb[i]):
					dec.append(i + 1)
			elif lista[i] < listb[i]:
				for j in range(listb[i] - lista[i]):
					inc.append(i + 1)
		print(len(dec))
		for i in range(len(dec)):
			print(dec[i], inc[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sq = []
	for i in range(n):
		for j in range(n):
			while a[i] < b[i] and a[j] > b[j]:
				a[i] += 1
				a[j] -= 1
				sq.append(f'{j + 1} {i + 1}')
	if a != b:
		print(-1)
	else:
		print(len(sq))
		if sq:
			print(*sq, sep='\n')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = []
	brr = []
	crr = []
	drr = []
	err = []
	for i in range(n):
		arr.append(a[i] - b[i])
	if sum(arr) != 0:
		print('-1')
		continue
	else:
		for i in range(len(arr)):
			if a[i] > b[i]:
				brr.append([i + 1] * abs(a[i] - b[i]))
			else:
				crr.append([i + 1] * abs(a[i] - b[i]))
	for i in brr:
		drr.extend(i)
	for i in crr:
		err.extend(i)
	ar = list(zip(drr, err))
	print(len(list(ar)))
	for (i, j) in ar:
		print(i, j)


from __future__ import division, print_function
from math import sqrt, gcd, ceil, floor, log, factorial
from itertools import permutations, combinations
from collections import Counter, defaultdict
from heapq import nsmallest, nlargest, heapify, heappop, heappush, heapreplace
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
import os, sys, math
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def msi():
	return map(str, input().split())

def li():
	return list(mi())

def add_set():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
mod = 1000000007

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPower2(x):
	return x and (not x & x - 1)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	t = ii()
	for _ in range(t):
		n = ii()
		a = li()
		b = li()
		(dec, inc) = (0, 0)
		(ine, de) = ([], [])
		for i in range(n):
			if a[i] > b[i]:
				dec += a[i] - b[i]
				de += [i + 1] * (a[i] - b[i])
			elif a[i] < b[i]:
				inc += b[i] - a[i]
				ine += [i + 1] * (b[i] - a[i])
		if inc == dec:
			print(inc)
			for j in range(inc):
				print(de[j], ine[j])
		else:
			print(-1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
solve()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if sum(a) != sum(b):
		print(-1)
		continue
	ans = []
	for i in range(n):
		for j in range(n):
			while a[i] > b[i]:
				if a[j] < b[j]:
					ans.append((i + 1, j + 1))
					a[i] -= 1
					a[j] += 1
				else:
					break
	print(len(ans))
	for i in range(len(ans)):
		print(*ans[i])


T = int(input())
for t in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = []
	if sum(a) != sum(b):
		print(-1)
	else:
		inc = []
		dec = []
		for i in range(n):
			if a[i] < b[i]:
				inc.append([i + 1, b[i] - a[i]])
			elif a[i] > b[i]:
				dec.append([i + 1, a[i] - b[i]])
		i = 0
		j = 0
		while i < len(inc) and j < len(dec):
			k.append([dec[j][0], inc[i][0]])
			dec[j][1] -= 1
			inc[i][1] -= 1
			if dec[j][1] < 1:
				j += 1
			if inc[i][1] < 1:
				i += 1
		print(len(k))
		for i in range(len(k)):
			print(*k[i])


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if sum(arr) != sum(arr2):
		print(-1)
	else:
		res = []
		for x in range(n):
			if arr[x] < arr2[x]:
				for y in range(n):
					if arr[y] > arr2[y]:
						k = min(arr2[x] - arr[x], arr[y] - arr2[y])
						arr[x] += k
						arr[y] -= k
						for _ in range(k):
							res.append([y + 1, x + 1])
		for x in range(n):
			if arr[x] > arr2[x]:
				for y in range(n):
					if arr[y] < arr2[y]:
						k = min(arr[x] - arr2[x], arr2[y] - arr[y])
						arr[x] -= k
						arr[y] += k
						for _ in range(k):
							res.append([x + 1, y + 1])
		print(len(res))
		for x in res:
			print(*x)


def not_verified(res):
	if sum(res) != 0:
		return True
	else:
		return False

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = []
	for i in range(n):
		res.append(b[i] - a[i])
	if not_verified(res):
		print(-1)
		return -1
	pos = []
	neg = []
	for i in range(n):
		if res[i] > 0:
			pos.extend([i + 1] * res[i])
		else:
			neg.extend([i + 1] * abs(res[i]))
	print(len(pos))
	for i in range(len(pos)):
		print(neg[i], pos[i], sep=' ')
	return
for i in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	input()
	xs = list(map(int, input().split()))
	ys = list(map(int, input().split()))
	adds = []
	rems = []
	for (i, (x, y)) in enumerate(zip(xs, ys)):
		d = y - x
		for _ in range(0, d):
			adds.append(i)
		for _ in range(d, 0):
			rems.append(i)
	if len(adds) != len(rems) or len(adds) > 100:
		print(-1)
		continue
	print(len(adds))
	for (r, a) in zip(rems, adds):
		print(r + 1, a + 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = 0
	(inc, dec) = ([], [])
	for i in range(n):
		diff = a[i] - b[i]
		if diff > 0:
			dec += diff * [i + 1]
		elif diff < 0:
			inc += abs(diff) * [i + 1]
		s += diff
	if s == 0:
		print(len(inc))
		for (i, j) in zip(inc, dec):
			print(j, i)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	s = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	posi = []
	nega = []
	p = 0
	if a == b:
		print(0)
	else:
		for i in range(s):
			if a[i] - b[i] != 0:
				p += b[i] - a[i]
				if b[i] - a[i] > 0:
					for k in range(b[i] - a[i]):
						posi.append(i + 1)
				elif b[i] - a[i] < 0:
					for k in range(abs(b[i] - a[i])):
						nega.append(i + 1)
		if p == 0:
			print(len(posi))
			for i in range(len(posi)):
				print(nega[i], posi[i])
		else:
			print(-1)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		c = [a[i] - b[i] for i in range(n)]
		(p, q) = ([], [])
		if sum(c) != 0:
			print('-1')
		else:
			ans = sum([i for i in c if i >= 0])
			print(ans)
			for i in range(n):
				if c[i] != 0:
					if c[i] < 0:
						for j in range(abs(c[i])):
							q.append(i)
					else:
						for j in range(c[i]):
							p.append(i)
			for i in range(len(p)):
				print(p[i] + 1, q[i] + 1)
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	q = list(map(int, input().split()))
	large = []
	small = []
	for i in range(len(z)):
		if z[i] > q[i]:
			large.append(i)
		elif z[i] < q[i]:
			small.append(i)
	i = 0
	j = 0
	ans = []
	flag = 0
	for i in range(len(small)):
		t = small[i]
		while j < len(large) and z[t] != q[t]:
			m = large[j]
			if z[m] == q[m]:
				j += 1
				continue
			ans.append([m + 1, t + 1])
			z[t] += 1
			z[m] -= 1
		if z[t] != q[t]:
			flag = 1
			break
	for i in range(len(z)):
		if z[i] != q[i]:
			flag = 1
			break
	if flag == 1:
		print(-1)
		continue
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


import os
import sys
from io import BytesIO, IOBase
from collections import *
from heapq import *
from math import *
ONLINE_JUDGE = 1

def main():
	for _ in range(int(input())):
		n = int(input())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		if sum(a) != sum(b):
			print('-1')
			continue
		diff = [a[i] - b[i] for i in range(n)]
		(res, cnt) = ([], 0)
		(i, j) = (0, 0)
		while i < n and j < n:
			if diff[i] == 0:
				i += 1
				continue
			if diff[j] == 0:
				j += 1
				continue
			while diff[j] < 0:
				j += 1
			while diff[i] > 0:
				i += 1
			m = min(abs(diff[i]), diff[j])
			diff[i] += m
			diff[j] -= m
			cnt += m
			for _ in range(m):
				res.append((j + 1, i + 1))
		print(cnt)
		for (i, j) in res:
			print(i, j)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
if not ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
main()


for _ in range(int(input())):
	n = int(input())
	A = [*map(int, input().split())]
	B = [*map(int, input().split())]
	pos = []
	neg = []
	for i in range(n):
		diff = A[i] - B[i]
		if diff > 0:
			neg += [i + 1] * diff
		elif diff < 0:
			pos += [i + 1] * -diff
	if len(pos) != len(neg):
		print(-1)
	else:
		print(len(pos))
		for (i, j) in zip(neg, pos):
			print(i, j)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print('-1')
	else:
		bh = []
		g = []
		for i in range(0, n):
			if a[i] > b[i]:
				diff = a[i] - b[i]
				bh.extend([i for j in range(diff)])
			if a[i] < b[i]:
				dif = b[i] - a[i]
				g.extend([i for j in range(dif)])
		print(len(bh))
		for i in range(0, len(bh)):
			print(str(int(bh[i]) + 1) + ' ' + str(int(g[i] + 1)))
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	ans = 0
	an = []
	for i in range(n):
		if a[i] != b[i]:
			if a[i] < b[i]:
				j = i + 1
				while a[i] != b[i]:
					if a[j] > b[j]:
						a[j] -= 1
						a[i] += 1
						ans += 1
						an += [[j + 1, i + 1]]
					else:
						j += 1
			elif a[i] > b[i]:
				j = i + 1
				while a[i] != b[i]:
					if a[j] < b[j]:
						a[j] += 1
						a[i] -= 1
						ans += 1
						an += [[i + 1, j + 1]]
					else:
						j += 1
	print(ans)
	for i in an:
		print(*i)


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	dec = []
	inc = []
	for (i, (a, b)) in enumerate(zip(A, B)):
		if a > b:
			d = a - b
			dec += [i + 1] * d
		elif a < b:
			d = b - a
			inc += [i + 1] * d
	if len(dec) == len(inc):
		print(len(dec))
		for (i, j) in zip(dec, inc):
			print(i, j)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if a == b:
		print(0)
	else:
		element = 0
		diff = []
		for i in range(n):
			diff.append(a[i] - b[i])
			if a[i] - b[i] > 0:
				element += a[i] - b[i]
		if sum(diff) != 0:
			print(-1)
		else:
			print(element)
			for i in range(n - 1):
				if diff[i] < 0:
					j = i + 1
					while diff[i] != 0:
						if diff[j] > 0:
							step = min(abs(diff[i]), abs(diff[j]))
							for _ in range(step):
								print(j + 1, i + 1)
							diff[i] += step
							diff[j] -= step
						j += 1
				if diff[i] > 0:
					j = i + 1
					while diff[i] != 0:
						if diff[j] < 0:
							step = min(abs(diff[i]), abs(diff[j]))
							for _ in range(step):
								print(i + 1, j + 1)
							diff[i] -= step
							diff[j] += step
						j += 1


from typing import Counter
import sys
from collections import defaultdict as dd
from math import *

def vinp():
	return map(int, input().split())

def linp():
	return list(map(int, input().split()))

def sinp():
	return input()

def inp():
	return int(input())

def mod(f):
	return f % 1000000007

def pr(*x):
	print(*x)

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def finp():
	f = open('input.txt', 'r')
	f = f.read().split('\n')
	return f

def fout():
	return open('output.txt', 'w')

def fpr(f, x):
	f.write(x + '\n')

def csort(c):
	sorted(c.items(), key=lambda pair: pair[1], reverse=True)

def indc(l, n):
	c = {}
	for i in range(n):
		c[l[i]] = c.get(l[i], []) + [i + 1]
	return c
cou = inp()
for i in range(cou):
	(n, a, b) = (inp(), linp(), linp())
	if a == b:
		pr(0)
	else:
		(pre, f, c, s) = ([], [], 0, '')
		for i in range(n):
			pre.append(b[i] - a[i])
		if sum(pre) == 0:
			for i in range(n):
				if pre[i] > 0:
					j = 0
					for j in range(n):
						while pre[j] < 0 and pre[i]:
							c += 1
							s += f'\n{j + 1} {i + 1}'
							pre[j] += 1
							pre[i] -= 1
			pr(c)
			if c != 0:
				print(s.strip())
		else:
			pr(-1)


t = int(input())
for tests in range(t):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	if sum(a) != sum(b):
		print(-1)
		continue
	ans = []
	l = 0
	g = 0
	while True:
		while l < len(a) and a[l] >= b[l]:
			l += 1
		while g < len(a) and a[g] <= b[g]:
			g += 1
		if g == len(a) or l == len(a):
			break
		a[l] += 1
		a[g] -= 1
		ans.append([g + 1, l + 1])
	print(len(ans))
	for i in range(len(ans)):
		print(ans[i][0], ans[i][1])


from collections import Counter, defaultdict
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sumo = 0
	d = defaultdict(list)
	neg = []
	pos = []
	ans = 0
	for i in range(n):
		if a[i] != b[i]:
			sumo += a[i] - b[i]
			if a[i] > b[i]:
				neg.append([i + 1, a[i] - b[i]])
				ans += a[i] - b[i]
			else:
				pos.append([i + 1, b[i] - a[i]])
				ans += b[i] - a[i]
	if sumo != 0:
		print(-1)
		continue
	print(ans // 2)
	nneg = len(neg)
	npos = len(pos)
	i = 0
	j = 0
	while i < nneg and j < npos:
		diff = min(neg[i][1], pos[j][1])
		pos[j][1] -= diff
		neg[i][1] -= diff
		while diff:
			diff -= 1
			print(neg[i][0], pos[j][0])
		if neg[i][1] == 0:
			i += 1
		else:
			j += 1


t = 1
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	needm = 0
	need = [0 for i in range(n)]
	needb = 0
	for i in range(n):
		if a[i] > b[i]:
			needm += a[i] - b[i]
			need[i] -= a[i] - b[i]
		if a[i] < b[i]:
			needb += b[i] - a[i]
			need[i] += b[i] - a[i]
	if needm != needb:
		print(-1)
	else:
		print(needb)
		for i in range(needb):
			nm = True
			nb = True
			ans = [0, 0]
			for j in range(n):
				if need[j] < 0 and nm:
					ans[0] = j + 1
					need[j] += 1
					nm = False
				elif need[j] > 0 and nb:
					ans[1] = j + 1
					need[j] -= 1
					nb = False
				if not nm and (not nb):
					break
			print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(y) for y in input().split()]
	if sum(a) != sum(b):
		print(-1)
	elif a == b:
		print(0)
	else:
		m = 0
		pos = []
		neg = []
		for i in range(n):
			m = m + abs(a[i] - b[i])
			if a[i] - b[i] > 0:
				for j in range(a[i] - b[i]):
					pos.append(i + 1)
			elif a[i] - b[i] < 0:
				for j in range(b[i] - a[i]):
					neg.append(i + 1)
		print(int(m / 2))
		for h in range(len(pos)):
			print(pos[h], neg[h])


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		if sum(a) == sum(b):
			ans = []
			i = 0
			while i < n:
				if a[i] == b[i]:
					i += 1
					continue
				elif a[i] > b[i]:
					for j in range(n):
						if j == i:
							continue
						if a[j] < b[j]:
							ans.append((i + 1, j + 1))
							a[i] -= 1
							a[j] += 1
							break
				else:
					for j in range(n):
						if j == i:
							continue
						if a[j] > b[j]:
							ans.append((j + 1, i + 1))
							a[i] += 1
							a[j] -= 1
							break
			print(len(ans))
			for item in ans:
				print(*item)
		else:
			print(-1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if sum(a) != sum(b):
		print(-1)
	else:
		count = 0
		down = []
		up = []
		for i in range(n):
			if a[i] > b[i]:
				for j in range(a[i] - b[i]):
					down.append(i + 1)
			elif a[i] < b[i]:
				for j in range(-a[i] + b[i]):
					up.append(i + 1)
		print(len(up))
		for i in range(len(up)):
			print(down[i], up[i])


for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = []
	neg = []
	sum1 = 0
	for i in range(n):
		d = b[i] - a[i]
		sum1 += d
		if d > 0:
			for j in range(d):
				pos.append(i)
		else:
			for j in range(abs(d)):
				neg.append(i)
	if sum1 == 0:
		print(len(pos))
		for (i, j) in zip(pos, neg):
			print(j + 1, i + 1)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) == sum(b):
		l1 = []
		l2 = []
		for j in range(n):
			c = a[j] - b[j]
			if c < 0:
				for k in range(abs(c)):
					l1.append(j + 1)
			else:
				for k in range(c):
					l2.append(j + 1)
		print(len(l1))
		for j in range(len(l1)):
			print(l2[j], l1[j])
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(c) for c in input().split()]
	b = [int(d) for d in input().split()]
	x1 = sum(a)
	x2 = sum(b)
	if x1 != x2:
		print(-1)
	elif a == b:
		print(0)
	else:
		s = 0
		for h in range(n):
			s += abs(a[h] - b[h])
		print(s // 2)
		for i in range(n):
			for j in range(n):
				if a[i] > b[i] and a[j] < b[j]:
					while a[i] != b[i] and a[j] != b[j]:
						a[i] -= 1
						a[j] += 1
						print(i + 1, j + 1)
				elif a[i] < b[i] and a[j] > b[j]:
					while a[j] > 0 and a[i] != b[i] and (a[j] != b[j]):
						a[i] += 1
						a[j] -= 1
						print(j + 1, i + 1)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

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

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	n = inp()
	a = li()
	b = li()
	if sum(a) != sum(b):
		pr(-1)
		return
	(x, y) = ([], [])
	for i in range(n):
		if a[i] > b[i]:
			x.append([i, a[i] - b[i]])
		elif a[i] < b[i]:
			y.append([i, b[i] - a[i]])
	ans = []
	for i in range(len(y)):
		while y[i][1]:
			for j in range(len(x)):
				if x[j][1] > 0:
					ans.append((x[j][0] + 1, y[i][0] + 1))
					x[j][1] -= 1
					break
			y[i][1] -= 1
	print(len(ans))
	for i in ans:
		print(*i)
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	smaller = []
	greater = []
	sum_A = sum(A)
	sum_B = sum(B)
	if sum_A != sum_B:
		print(-1)
	else:
		for i in range(n):
			if A[i] < B[i]:
				smaller.append([i + 1, B[i] - A[i]])
			elif A[i] > B[i]:
				greater.append([i + 1, A[i] - B[i]])
		res = []
		(i, j) = (0, 0)
		while i < len(smaller) and j < len(greater):
			while smaller[i][1] > 0 and greater[j][1] > 0:
				res.append([greater[j][0], smaller[i][0]])
				smaller[i][1] -= 1
				greater[j][1] -= 1
			if smaller[i][1] == 0:
				i += 1
			if greater[j][1] == 0:
				j += 1
		print(len(res))
		for (i, j) in res:
			print(i, j)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	if sum(a) != sum(b):
		print(-1)
		continue
	less = []
	more = []
	for i in range(n):
		if a[i] > b[i]:
			more += [[a[i] - b[i], i]]
		elif a[i] < b[i]:
			less += [[b[i] - a[i], i]]
	ans = []
	ptr1 = 0
	ptr2 = 0
	while ptr1 != len(more) and ptr2 != len(less):
		if more[ptr1][0] == 0:
			ptr1 += 1
			continue
		if less[ptr2][0] == 0:
			ptr2 += 1
			continue
		ans += [[more[ptr1][1] + 1, less[ptr2][1] + 1]]
		more[ptr1][0] -= 1
		less[ptr2][0] -= 1
	print(len(ans))
	for x in ans:
		print(*x)


T = int(input())
for _ 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):
		if A[i] > B[i]:
			for j in range(A[i] - B[i]):
				C.append(i + 1)
		elif B[i] > A[i]:
			for j in range(B[i] - A[i]):
				D.append(i + 1)
	if len(D) != len(C):
		print(-1)
	else:
		print(len(D))
		for j in range(len(D)):
			print(C[j], D[j])


import math

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if sum(A) != sum(B):
		print(-1)
		return
	diffs = [A[i] - B[i] for i in range(n)]
	(inc, dec) = ([], [])
	for (idx, diff) in enumerate(diffs):
		if diff > 0:
			for _ in range(abs(diff)):
				dec.append(idx)
		elif diff < 0:
			for _ in range(abs(diff)):
				inc.append(idx)
	print(len(inc))
	for i in range(len(inc)):
		print(dec[i] + 1, inc[i] + 1)
for _ in range(int(input())):
	solve()


import math

def intlist():
	return [int(i) for i in input().split(' ')]

def stringlist():
	return input().split(' ')

def yes(t):
	if t:
		return 'YES'
	return 'NO'

def printjoin(l, str=False):
	if str:
		l = [str(i) for i in l]
	return ' '.join(l)

def power_of_two(n):
	b = bin(n)[2:]
	return int(b) == 10 ** (len(b) - 1)

def bit_count(n):
	return bin(n).count('1')

def solve():
	n = int(input())
	a = intlist()
	b = intlist()
	c = []
	for i in range(n):
		c.append(b[i] - a[i])
	s = sum(c)
	ans = []
	if s != 0:
		return -1
	for i in range(n):
		if c[i] <= 0:
			continue
		while c[i] > 0:
			for j in range(n):
				if c[j] < 0:
					k = j
					break
			if c[i] > -1 * c[k]:
				for ii in range(-1 * c[k]):
					ans.append('{} {}'.format(k + 1, i + 1))
				c[i] = c[i] + c[k]
				c[k] = 0
			else:
				for ii in range(c[i]):
					ans.append('{} {}'.format(k + 1, i + 1))
				c[k] += c[i]
				c[i] = 0
	return ans
t = input()
for tt in range(int(t)):
	a = solve()
	if a == -1:
		print(a)
	else:
		print(len(a))
		for i in a:
			print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = []
	i = []
	btotal = sum(b)
	atotal = sum(a)
	if atotal != btotal:
		print(-1)
	else:
		for x in range(n):
			if b[x] - a[x] < 0:
				for j in range(abs(a[x] - b[x])):
					i.append(x + 1)
			elif b[x] - a[x] > 0:
				for h in range(abs(a[x] - b[x])):
					d.append(x + 1)
			else:
				pass
		if len(d) > 0:
			print(len(d))
			for x in range(len(d)):
				print(i[x], d[x])
		else:
			print(0)


for i in range(int(input())):
	n = int(input())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	sum1 = 0
	sum2 = 0
	sum3 = 0
	for i in range(n):
		sum1 += li1[i]
		sum2 += li2[i]
		sum3 += abs(li1[i] - li2[i])
	if sum1 != sum2:
		print(-1)
	else:
		print(sum3 // 2)
		for i in range(n - 1):
			if li1[i] > li2[i]:
				while li1[i] != li2[i]:
					j = i + 1
					while li1[j] >= li2[j]:
						j += 1
					li1[j] += 1
					li1[i] -= 1
					print(i + 1, j + 1)
			elif li1[i] < li2[i]:
				while li1[i] != li2[i]:
					j = i + 1
					while li1[j] <= li2[j]:
						j += 1
					li1[j] -= 1
					li1[i] += 1
					print(j + 1, i + 1)
			else:
				continue


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	I = []
	J = []
	if sum(a) == sum(b):
		for i in range(n):
			if a[i] > b[i]:
				time = a[i] - b[i]
				for x in range(time):
					I.append(i)
			elif a[i] < b[i]:
				time = b[i] - a[i]
				for x in range(time):
					J.append(i)
		print(len(I))
		for i in range(len(I)):
			print(I[i] + 1, J[i] + 1)
	else:
		print(-1)


t = int(input())
for _ in range(0, t):
	a = int(input())
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = []
	e = []
	k = []
	for ele in range(0, len(b)):
		if b[ele] == c[ele]:
			pass
		elif b[ele] > c[ele]:
			d.append([b[ele] - c[ele], ele])
		elif c[ele] > b[ele]:
			e.append([c[ele] - b[ele], ele])
	su = 0
	suu = 0
	f = []
	for ele in range(0, len(d)):
		su = su + d[ele][0]
	for ele in range(0, len(e)):
		suu = suu + e[ele][0]
	if su == suu:
		for ele in range(0, len(d)):
			for m in range(0, d[ele][0]):
				k.append(d[ele][1])
		for ele in range(0, len(e)):
			for m in range(0, e[ele][0]):
				f.append(e[ele][1])
		print(su)
		for ele in range(0, len(f)):
			print(k[ele] + 1, f[ele] + 1)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	d = []
	if a == b:
		print(0)
	elif sorted(a) == sorted(b) or sum(a) == sum(b):
		d = []
		c = 0
		for i in range(n):
			j = 0
			while a[i] - b[i] > 0:
				while a[j] - b[j] < 0 and a[i] - b[i] > 0:
					d.append((i + 1, j + 1))
					c += 1
					a[i] -= 1
					a[j] += 1
				j += 1
			while a[i] - b[i] < 0:
				while a[j] - b[j] > 0 and a[i] - b[i] < 0:
					d.append((j + 1, i + 1))
					c += 1
					a[i] += 1
					a[j] -= 1
				j += 1
		print(c)
		for i in d:
			print(*i)
	else:
		print(-1)


test_case = int(input())
while test_case:
	lst1 = []
	lst2 = []
	n = int(input())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	if sum(a) == sum(b):
		for i in range(n):
			if a[i] == b[i]:
				continue
			elif a[i] > b[i]:
				c = a[i] - b[i]
				for j in range(c):
					lst1.append(i)
				a[i] += c
			else:
				c = b[i] - a[i]
				for j in range(c):
					lst2.append(i)
				a[i] += c
		print(len(lst1))
		for i in range(len(lst1)):
			print(lst1[i] + 1, lst2[i] + 1)
	else:
		print('-1')
	test_case -= 1


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	if sum(A) != sum(B):
		print(-1)
		continue
	al = []
	bl = []
	for i in range(N):
		if A[i] > B[i]:
			al.extend([i + 1] * (A[i] - B[i]))
		elif A[i] < B[i]:
			bl.extend([i + 1] * (B[i] - A[i]))
	print(len(al))
	for (a, b) in zip(al, bl):
		print(a, b)


t = int(input())
for i in range(t):
	n = int(input())
	a = 0
	b = 0
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	for j in range(n):
		a += x[j]
		b += y[j]
	if a == b:
		pos = []
		neg = []
		for j in range(n):
			if x[j] > y[j]:
				c = x[j] - y[j]
				while c:
					pos.append(j + 1)
					c -= 1
			elif x[j] < y[j]:
				c = y[j] - x[j]
				while c:
					neg.append(j + 1)
					c -= 1
		print(len(pos))
		for j in range(len(pos)):
			print(f'{pos[j]} {neg[j]}')
	else:
		print(-1)


import math

def getint():
	return [int(i) for i in input().split()]

def getstr():
	return [str(i) for i in input().split()]

def solve():
	n = int(input())
	a = getint()
	b = getint()
	if a == b:
		print(0)
		return
	c = [0] * n
	for i in range(n):
		c[i] = a[i] - b[i]
	if sum(c) != 0:
		print(-1)
		return
	count = 0
	for i in c:
		if i > 0:
			count += i
	print(count)
	ansi = []
	ansj = []
	for i in range(n):
		if c[i] > 0:
			ansi += [i + 1] * c[i]
		elif c[i] < 0:
			ansj += [i + 1] * abs(c[i])
	for i in range(count):
		print(ansi[i], ansj[i])
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	neg = []
	pos = []
	s = 0
	for i in range(n):
		s += a[i] - b[i]
		if a[i] - b[i] < 0:
			neg.append(i)
		elif a[i] - b[i] > 0:
			pos.append(i)
	if s != 0:
		print(-1)
		continue
	res = []
	cnt = 0
	while pos and neg:
		res.append([pos[0] + 1, neg[0] + 1])
		a[neg[0]] += 1
		a[pos[0]] -= 1
		if a[neg[0]] == b[neg[0]]:
			neg.pop(0)
		if a[pos[0]] == b[pos[0]]:
			pos.pop(0)
		cnt += 1
	print(cnt)
	for r in res:
		print(*r)


n = int(input())
ListaNArr = []
ListArr1 = []
ListArr2 = []
ListI = []
ListJ = []

def NuevaLista(k, n):
	LN = k.split(' ', n)
	for i in range(len(LN)):
		LN[i] = int(LN[i])
	return LN

def intentos(n, n1, n2):
	global Flag
	Flag = False
	for l in range(102):
		if n1 == n2:
			print(l)
			break
		elif l == 101:
			print(-1)
			break
		else:
			i = recorrer(n, n1, n2)
			j = recorrer2(n, n1, n2)
			if i is None or j is None:
				print(-1)
				Flag = True
				break
			else:
				n1[i] = n1[i] - 1
				n1[j] = n1[j] + 1
				ListI.append(i)
				ListJ.append(j)

def recorrer(n, n1, n2):
	for i in range(len(n1)):
		if n1[i] > n2[i]:
			return i

def recorrer2(n, n1, n2):
	for j in range(len(n1)):
		if n1[j] < n2[j]:
			return j
for a in range(n):
	L1 = int(input())
	L2 = input()
	L3 = input()
	ListaNArr.append(L1)
	ListArr1.append(L2)
	ListArr2.append(L3)
for b in range(len(ListaNArr)):
	ListI = []
	ListJ = []
	n1 = NuevaLista(ListArr1[b], ListaNArr[b])
	n2 = NuevaLista(ListArr2[b], ListaNArr[b])
	intentos(len(n1), n1, n2)
	if ListJ != [] and Flag == False:
		for a in range(len(ListJ)):
			print(ListI[a] + 1, ListJ[a] + 1)


from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys
import copy
inf_var = 0
if inf_var == 1:
	inf = open('input.txt', 'r')
else:
	inf = sys.stdin
input = inf.readline

def read_one_int():
	return int(input().rstrip('\n'))

def read_one_float():
	return float(input().rstrip('\n'))

def read_list_of_ints():
	res = [int(val) for val in input().rstrip('\n').split(' ')]
	return res

def read_str():
	return input().rstrip()

def main():
	tests = read_one_int()
	for _ in range(tests):
		n = read_one_int()
		a = read_list_of_ints()
		b = read_list_of_ints()
		el_to_decr = []
		el_to_incr = []
		for i in range(n):
			if a[i] - b[i] < 0:
				for _ in range(b[i] - a[i]):
					el_to_incr.append(i + 1)
				continue
			if a[i] - b[i] > 0:
				for _ in range(a[i] - b[i]):
					el_to_decr.append(i + 1)
		if len(el_to_decr) != len(el_to_incr):
			print(-1)
			continue
		print(len(el_to_decr))
		for i in range(len(el_to_decr)):
			print('{} {}'.format(el_to_decr[i], el_to_incr[i]))
main()


import sys
import math
import bisect
import heapq
from bisect import bisect_right
from sys import stdin, stdout

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

def get_int():
	return int(sys.stdin.readline())

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

def get_list_of_list(n):
	return [list(map(int, sys.stdin.readline().strip().split())) for _ in range(n)]

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

def myceil(x, y):
	return (x + y - 1) // y

def Solution(a, b, n):
	res = []
	for i in range(n):
		if a[i] == b[i]:
			continue
		req = abs(a[i] - b[i])
		for j in range(n):
			if req == 0:
				break
			if i == j:
				continue
			if a[i] < b[i] and a[j] > b[j]:
				tmp = min(req, abs(a[j] - b[j]))
				req -= tmp
				a[i] += tmp
				a[j] -= tmp
				for _ in range(tmp):
					res.append([j + 1, i + 1])
			elif a[i] > b[i] and a[j] < b[j]:
				tmp = min(req, abs(a[j] - b[j]))
				req -= tmp
				a[i] -= tmp
				a[j] += tmp
				for _ in range(tmp):
					res.append([i + 1, j + 1])
	for i in range(n):
		if a[i] != b[i]:
			print(-1)
			return
	print(len(res))
	for v in res:
		print(*v)

def main():
	for _ in range(get_int()):
		n = get_int()
		a = get_ints_in_list()
		b = get_ints_in_list()
		Solution(a, b, n)
main()


import sys

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

def readint():
	return int(readstr())

def readints():
	return map(int, readstr().split())

def solve(a, b, n):
	diff1 = 0
	diff2 = 0
	for i in range(n):
		if a[i] > b[i]:
			diff1 += a[i] - b[i]
		else:
			diff2 += b[i] - a[i]
	if diff1 - diff2 != 0:
		print(-1)
		return
	print(diff1)
	for i in range(n):
		if a[i] > b[i]:
			c = a[i] - b[i]
			while c != 0:
				for j in range(n):
					if a[j] < b[j]:
						m = min(c, b[j] - a[j])
						c -= m
						a[j] += m
						for _ in range(m):
							print(str(i + 1) + ' ' + str(j + 1))
			a[i] = b[i]
		else:
			c = b[i] - a[i]
			while c != 0:
				for j in range(n):
					if a[j] > b[j]:
						m = min(c, a[j] - b[j])
						c -= m
						a[j] -= m
						for _ in range(m):
							print(str(j + 1) + ' ' + str(i + 1))
			a[i] = b[i]

def main():
	t = readint()
	for _ in range(t):
		n = readint()
		a = list(readints())
		b = list(readints())
		solve(a, b, n)
main()


def solve():
	s = 0
	lower = []
	higher = []
	for i in range(n):
		s += A[i] - B[i]
		if A[i] < B[i]:
			lower.append(i)
		elif A[i] > B[i]:
			higher.append(i)
	if s != 0:
		print(-1)
		return
	step = 0
	for val in lower:
		step += B[val] - A[val]
	print(step)
	idx_l = 0
	idx_h = 0
	while idx_l < len(lower) and idx_h < len(higher):
		print(higher[idx_h] + 1, lower[idx_l] + 1)
		A[lower[idx_l]] += 1
		A[higher[idx_h]] -= 1
		if A[lower[idx_l]] == B[lower[idx_l]]:
			idx_l += 1
		if A[higher[idx_h]] == B[higher[idx_h]]:
			idx_h += 1
	return
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	solve()


def process():
	n = int(input())
	a = input().split(' ')
	a = [int(i) for i in a]
	b = input().split(' ')
	b = [int(i) for i in b]
	if sum(a) != sum(b):
		print('-1')
		return
	greater = []
	smaller = []
	for i in range(len(a)):
		if a[i] > b[i]:
			greater.extend([i + 1] * (a[i] - b[i]))
		elif a[i] < b[i]:
			smaller.extend([i + 1] * (b[i] - a[i]))
	print(len(greater))
	for i in range(len(greater)):
		print(*(greater[i], smaller[i]))
t = int(input())
for _ in range(t):
	process()


import sys

def main():
	inp = [int(x) for x in sys.stdin.read().split()]
	ii = 0
	t = inp[ii]
	ii += 1
	for _ in range(t):
		n = inp[ii]
		ii += 1
		aar = inp[ii:ii + n]
		ii += n
		bar = inp[ii:ii + n]
		ii += n
		if sum(aar) != sum(bar):
			print(-1)
			continue
		diffs = []
		negs = []
		poss = []
		for i in range(n):
			k = aar[i] - bar[i]
			if k < 0:
				for _ in range(-k):
					negs.append(i)
			elif k > 0:
				for _ in range(k):
					poss.append(i)
		print(len(poss))
		for j in range(len(poss)):
			print(poss[j] + 1, negs[j] + 1)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
	elif a == b:
		print(0)
	else:
		l = []
		k = []
		s = 0
		for i in range(n):
			if a[i] > b[i]:
				l += [i + 1] * (a[i] - b[i])
				s += a[i] - b[i]
		for j in range(n):
			if b[j] - a[j]:
				k += [j + 1] * (b[j] - a[j])
		print(s)
		for mm in range(s):
			print(l[mm], k[mm])


for _ in range(int(input())):
	n = int(input())
	a = [int(num) for num in input().split()]
	b = [int(num) for num in input().split()]
	score = 0
	for ind in range(n):
		score += a[ind] - b[ind]
	if score != 0:
		print(-1)
	else:
		num_of_operations = 0
		operations = []
		for ind in range(n):
			if a[ind] > b[ind]:
				diff = a[ind] - b[ind]
				for ind2 in range(n):
					while a[ind] > b[ind] and a[ind2] < b[ind2]:
						num_of_operations += 1
						a[ind] -= 1
						a[ind2] += 1
						operations.append((ind + 1, ind2 + 1))
		print(num_of_operations)
		for pair in operations:
			print(*pair)


def program():
	n = int(input())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if sum(l1) != sum(l2):
		print(-1)
		return
	pos = []
	neg = []
	for i in range(n):
		dif = l1[i] - l2[i]
		if dif > 0:
			temp = [i + 1] * dif
			pos = pos + temp
		elif dif < 0:
			temp = [i + 1] * abs(dif)
			neg = neg + temp
	print(len(pos))
	for i in range(len(pos)):
		print(pos[i], neg[i])
for i in range(int(input())):
	program()


def solve(A, B):
	ops = []
	needToIncrease = []
	needToDecrease = []
	for idx in range(len(A)):
		if A[idx] < B[idx]:
			needToIncrease.append(idx)
		elif A[idx] > B[idx]:
			needToDecrease.append(idx)
	increaseIter = 0
	decreaseIter = 0
	while increaseIter < len(needToIncrease) and decreaseIter < len(needToDecrease):
		ops.append([needToDecrease[decreaseIter] + 1, needToIncrease[increaseIter] + 1])
		A[needToIncrease[increaseIter]] += 1
		A[needToDecrease[decreaseIter]] -= 1
		if A[needToIncrease[increaseIter]] == B[needToIncrease[increaseIter]]:
			increaseIter += 1
		if A[needToDecrease[decreaseIter]] == B[needToDecrease[decreaseIter]]:
			decreaseIter += 1
	canSolve = increaseIter == len(needToIncrease) and decreaseIter == len(needToDecrease)
	if canSolve:
		print(len(ops))
		for op in ops:
			print(' '.join(map(str, op)))
	else:
		print('-1')
t = int(input())
for test in range(1, t + 1):
	_ = input()
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	solve(A, B)


T = int(input())
for case in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	pos = []
	neg = []
	for i in range(n):
		ans = a[i] - b[i]
		if ans > 0:
			pos += [i] * ans
		elif ans < 0:
			neg += [i] * -ans
	if len(pos) != len(neg):
		print(-1)
		continue
	elif len(pos) == 0:
		print(0)
	else:
		print(len(pos), end='\n')
		for i in range(len(pos)):
			print(pos[i] + 1, neg[i] + 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if sum(a) != sum(b):
		print(-1)
		continue
	incList = [i - j for (i, j) in zip(a, b)]
	stepList = []
	for i in range(n - 1):
		if incList[i] == 0:
			continue
		if incList[i] > 0:
			for j in range(i + 1, n):
				if incList[i] == 0:
					break
				if incList[j] < 0:
					while incList[j] < 0 and incList[i] > 0:
						stepList.append((i + 1, j + 1))
						incList[i] -= 1
						incList[j] += 1
		else:
			for j in range(i + 1, n):
				if incList[j] > 0:
					while incList[j] > 0 and incList[i] < 0:
						stepList.append((j + 1, i + 1))
						incList[j] -= 1
						incList[i] += 1
	print(len(stepList))
	for (x, y) in stepList:
		print(x, y)