John is new to Mathematics and does not know how to calculate GCD of numbers. So he wants you to help him in a few GCD calculations. John has a list A of numbers, indexed 1 to N. He wants to create another list B having N+1 numbers, indexed from 1 to N+1, and having the following property:

GCD(B[i], B[i+1]) = A[i],  ∀ 1  ≤ i  ≤ N

As there can be many such lists, John wants to know the list B in which sum of all elements is minimum. It is guaranteed that such a list will always exist.

Input Format 

The first line contains an integer T, i.e., the number of the test cases. T testcases follow. 

The first line of each test case contains an integer N, i.e., the number of elements in the array. 

The second line of each test case contains N space separated integers that  denote the elements of the list A.  

Output Format 

For each test case, print in a new line the list B such that each element is separated by a single space. 

Constraints 

1 ≤ T ≤ 10 

2 ≤ N ≤ 10^{3} 

1 ≤ A[i] ≤ 10^{4} 

1 ≤ B[i]  

Sample Input  

2
3
1 2 3
3
5 10 5

Sample Output  

1 2 6 3
5 10 10 5

Explanation  

For the first testcase, 

 GCD(1,2) = 1
 GCD(2,6) = 2
 GCD(6,3) = 3
 sum = 1+2+6+3 = 12 which is minimum among all possible list B

For the second testcase, 

GCD(5, 10) = 5
GCD(10, 10) = 10
GCD(10, 5) = 5
sum = 5 + 10 + 10 + 5 = 30 which is the minimum among all possible list B

Difficulty: EASY

Solutions:
def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = [A[0]]
	for i in range(N - 1):
		B.append(lcm(A[i], A[i + 1]))
	B.append(A[N - 1])
	print(' '.join(map(str, B)))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)
for t in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	ans = [str(l[0])]
	for i in range(n - 1):
		ans.append(str(int(lcm(l[i], l[i + 1]))))
	ans += [str(l[-1])]
	print(' '.join(ans))


def gcd(a, b):
	if a > b:
		(a, b) = (b, a)
	while a > 0:
		(a, b) = (b % a, a)
	return b

def solve(A):
	A += [1]
	p = 1
	B = []
	for a in A:
		B.append(p * a // gcd(p, a))
		p = a
	return B
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	print(' '.join((str(_) for _ in solve(A))))


def primes(n):
	if n < 3:
		return []
	if n == 3:
		return [2]
	helper = [False, False, True] + [True for _ in range(n - 3)]
	for i in range(2, n):
		for j in range(2, n // i + 1):
			if i * j < n and helper[i * j]:
				helper[i * j] = False
	nums = [i for i in range(n)]
	return [nums[i] for i in range(n) if helper[i]]
primes = primes(10 ** 4)

def factor(n):
	r = {}
	if n <= 1:
		return r
	for i in primes:
		if n % i == 0:
			r[i] = 0
			while n % i == 0:
				r[i] += 1
				n /= i
		if i == 1:
			break
	return r

def solve():
	N = int(input())
	A = list(map(int, input().split(' ')))
	B = [A[0]]
	for i in range(1, N):
		B.append(A[i - 1])
		a = factor(A[i])
		b = factor(B[i])
		factored_b = dict(list(a.items()) + list(b.items()) + [(k, max(a[k], b[k])) for k in set(b) & set(a)])
		b = 1
		for f in factored_b:
			b *= f ** factored_b[f]
		B[i] = b
	B.append(A[-1])
	return ' '.join(map(str, B))
for case in range(int(input())):
	print(solve())


t = int(input())
for j in range(0, t):
	n = int(input())
	A = list(input())
	a = []
	x = ''
	count = 0
	for i in A:
		if i != ' ':
			x = x + i
		elif i == ' ':
			a.append(int(x))
			x = ' '
	a.append(int(x))
	b = []
	b.append(a[0])
	for j in range(1, n):
		add = min(a[j - 1], a[j])
		k = add
		found = 0
		while found == 0:
			if (k % a[j - 1] == 0) & (k % a[j] == 0):
				b.append(k)
				found = 1
			else:
				k += add
	b.append(a[n - 1])
	out = ''
	for m in range(0, n + 1):
		if m > 0:
			out += ' '
		out += str(b[m])
	print(out)


tests = int(input())
sets = []
maxv = 0
for i in range(0, tests):
	vals = int(input())
	cur = str(input()).split(' ')
	curset = []
	for j in range(0, vals):
		nowv = int(cur[j])
		if nowv > maxv:
			maxv = nowv
		curset.append(nowv)
	sets.append(curset)
primes = [2]
prim = 3
while prim <= maxv:
	pri = True
	for j in primes:
		if prim % j == 0:
			pri = False
			break
	if pri:
		primes.append(prim)
	prim += 2
for i in range(0, tests):
	prev = sets[i][0]
	print(prev, end=' ')
	for j in range(1, len(sets[i])):
		curv = sets[i][j]
		temp = prev * curv
		tp = prev
		tc = curv
		for pts in primes:
			while tp % pts == 0 and tc % pts == 0:
				temp /= pts
				tp /= pts
				tc /= pts
		print(int(temp), end=' ')
		prev = curv
	print(sets[i][len(sets[i]) - 1])


import math

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	temp = gcd(a, b)
	return a * b // temp
iteration = int(input())
for i in range(iteration):
	non = int(input())
	li = [int(x) for x in input().split()]
	anslist = list()
	anslist.append(str(li[0]))
	for j in range(non - 1):
		anslist.append(str(lcm(li[j], li[j + 1])))
	anslist.append(str(li[-1]))
	print(' '.join(anslist))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = [a[0]]
	for i in range(n - 1):
		b.append(lcm(a[i], a[i + 1]))
	b.append(a[-1])
	print(*b)


def gcd(a, b):
	while a != 0 and b != 0:
		(a, b) = (min((a, b)), max((a, b)) - min((a, b)))
	return a or b

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input().strip())):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	res = [a[0]]
	for i in range(1, len(a)):
		res.append(lcm(a[i - 1], a[i]))
	res.append(a[n - 1])
	print(' '.join(map(str, res)))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input())):
	elementCount = int(input())
	elements = [int(x) for x in input().split(' ')]
	output = [elements[0]]
	for i in range(1, len(elements)):
		output.append(lcm(elements[i], elements[i - 1]))
	output.append(elements[-1])
	print(' '.join((str(x) for x in output)))


def main():
	ncases = int(input())
	for _ in range(ncases):
		length = int(input())
		a = [int(fld) for fld in input().split()]
		assert len(a) == length
		print(' '.join(map(str, solve(a))))

def solve(a):
	return [x * y // gcd(x, y) for (x, y) in zip([1] + a, a + [1])]

def gcd(x, y):
	(xp2, x) = factor2s(x)
	(yp2, y) = factor2s(y)
	(x, y) = (max(x, y), min(x, y))
	while y != 0:
		(_, z) = factor2s(x - y)
		(x, y) = (max(y, z), min(y, z))
	return x << min(xp2, yp2)

def factor2s(n):
	if n == 0:
		return (0, 0)
	p2 = 0
	while n & 1 == 0:
		n >>= 1
		p2 += 1
	return (p2, n)
main()


def gcd(a, b):
	while b > 0:
		t = b
		b = a % b
		a = t
	return a
numtest = int(input())
for z in range(numtest):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	b.append(a[0])
	for i in range(n - 1):
		b.append(int(a[i] * a[i + 1] / gcd(a[i], a[i + 1])))
		print(b[i], end=' ')
	b.append(a[n - 1])
	print(b[n - 1], end=' ')
	print(b[n])


def lcm(a, b):
	if a > b:
		(a, b) = (b, a)
	(a1, b1) = (a, b)
	while b % a != 0:
		(b, a) = (a, b % a)
	return a1 * b1 // a
t = int(input())
for i in range(t):
	n = int(input())
	l = [1] + [int(i) for i in input().split()] + [1]
	temp = []
	for j in range(1, n + 2):
		temp.append(lcm(l[j], l[j - 1]))
	print(' '.join(map(str, temp)))


def gcd(a, b):
	if a == 0:
		return b
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return int(abs(a * b) / gcd(a, b))
n = int(input())
for i in range(n):
	t = int(input())
	a = [1] + [int(x) for x in input().split()] + [1]
	b = [None] * (len(a) - 1)
	for j in range(1, len(a)):
		b[j - 1] = lcm(a[j - 1], a[j])
	print(' '.join([str(x) for x in b]))


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

def lcm(x, y):
	return x * y // gcd(x, y)
t = int(input())
for j in range(t):
	n = int(input())
	A = input().split()
	A = list(map(int, A))
	(x, y) = (A[0], A[-1])
	B = [x]
	for i in range(n - 1):
		LCM = lcm(A[i], A[i + 1])
		B.append(LCM)
	B.append(y)
	B = list(map(str, B))
	print(' '.join(B))


def GCD(a, b):
	return GCD(b, a % b) if b else a

def LCM(a, b):
	return a * b // GCD(a, b)
t = int(input())
for _ in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	res = [lis[0]]
	for i in range(n - 1):
		res.append(LCM(lis[i], lis[i + 1]))
	res.append(lis[-1])
	print(' '.join(list(map(str, res))))


import string
exclude = set(string.punctuation)

def gcd(a, b):
	for i in range(min(a, b), 1, -1):
		if a % i == 0 and b % i == 0:
			return i
	return 1

def lcm(a, b):
	return a * b // gcd(a, b)
num_cases = int(input())
for _ in range(num_cases):
	length = int(input())
	array = input().split()
	array = [int(array[i]) for i in range(length)]
	result = [array[0]] * (length + 1)
	for i in range(1, length):
		result[i] = lcm(array[i - 1], array[i])
	result[length] = array[length - 1]
	print(''.join((ch for ch in str(result) if ch not in exclude)))


def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)
t = int(input())
for test in range(t):
	n = int(input())
	l = [int(x) for x in input().split()]
	print(l[0], end=' ')
	for i in range(n - 1):
		print(l[i] * l[i + 1] // gcd(l[i], l[i + 1]), end=' ')
	print(l[n - 1])


gcd = lambda x, y: gcd(y % x, x) if x else y
print(*(' '.join(map(str, (lambda n, x: [x[0]] + [x[i] * x[i + 1] // gcd(x[i], x[i + 1]) for i in range(n - 1)] + [x[-1]])(int(input()), list(map(int, input().split()))))) for _ in range(int(input()))), sep='\n')


def gcd(x, y):
	while y != 0:
		(x, y) = (y, x % y)
	return x
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split(' ')))
	print(arr[0], end=' ')
	for i in range(n - 1):
		print(arr[i] * arr[i + 1] // gcd(arr[i], arr[i + 1]), end=' ')
	print(arr[n - 1], end='\n')


def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input())):
	input()
	a = [1] + list(map(int, input().split())) + [1]
	b = [lcm(a[i], a[i + 1]) for i in range(len(a) - 1)]
	print(' '.join(map(str, b)))


def gcd(x, y):
	(x, y) = (max(x, y), min(x, y))
	if x == y:
		return x
	while y:
		(x, y) = (y, x % y)
	return x
t = int(input())
for _ in range(t):
	_ = input()
	A = [int(i) for i in input().split()]
	B = []
	B.append(A[0])
	for i in range(1, len(A)):
		b = B[i - 1]
		if b <= A[i]:
			while b % A[i] != 0:
				b += A[i - 1]
		else:
			b = A[i]
			while b % A[i - 1] != 0:
				b += A[i]
		B.append(b)
	B.append(A[-1])
	print(' '.join([str(b) for b in B]))


gcd_cache = {}

def gcd(a, b):
	if (a, b) not in gcd_cache:
		if b < 1:
			r = a
		elif a < b:
			r = gcd(b, a)
		else:
			r = gcd(b, a % b)
		gcd_cache[a, b] = r
	return gcd_cache[a, b]

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input().strip())):
	n = int(input().strip())
	alist = [int(c) for c in input().strip().split(' ')]
	p = alist.pop(0)
	rlist = [p]
	while alist:
		a = alist.pop(0)
		rlist.append(lcm(p, a))
		p = a
	rlist.append(p)
	print(' '.join((str(i) for i in rlist)))


for t0 in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	b.append(a[0])
	for i in range(len(a) - 1):
		x = 1
		while True:
			if x % a[i] == 0 and x % a[i + 1] == 0:
				b.append(x)
				break
			x = x + 1
	b.append(a[-1])
	print(*b)


t = int(input())

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split(' ')]
	B = [1] * (len(A) + 1)
	for i in range(len(B)):
		if i == 0:
			B[i] = A[i]
		elif i == len(B) - 1:
			B[i] = A[len(A) - 1]
		else:
			B[i] = lcm(A[i], A[i - 1])
	print(' '.join([str(x) for x in B]))


from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)

def solve():
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	B.append(A[0])
	for i in range(n - 1):
		B.append(lcm(A[i], A[i + 1]))
	B.append(A[-1])
	print(' '.join(map(str, B)))

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


def gcd(a, b):
	if b < a:
		(a, b) = (b, a)
	while b % a:
		(a, b) = (b % a, a)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)
T = int(input())
for _ in range(T):
	input()
	A = list(map(int, input().split()))
	B = [A[0]]
	for (a, b) in zip(A[:-1], A[1:]):
		B.append(lcm(a, b))
	B.append(A[-1])
	print(' '.join(map(str, B)))


from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(a[0], end=' ')
	for i in range(n - 1):
		print(lcm(a[i], a[i + 1]), end=' ')
	print(a[n - 1])


def nod(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(a[0], end=' ')
	for j in range(n - 1):
		print(a[j] * a[j + 1] // nod(a[j], a[j + 1]), end=' ')
	print(a[n - 1])


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	ar = [int(x) for x in input().split()]
	print(ar[0], end=' ')
	for i in range(1, n):
		print(lcm(ar[i - 1], ar[i]), end=' ')
	print(ar[-1])


t = int(input())

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
while t:
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(arr[0], end=' ')
	for k in range(n - 1):
		print(arr[k] * arr[k + 1] // gcd(arr[k], arr[k + 1]), end=' ')
	print(arr[n - 1])
	t -= 1


import math
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(x) for x in input().split()]
	B = [0] * (N + 1)
	B[0] = A[0]
	B[N] = A[N - 1]
	for i in range(1, N):
		B[i] = A[i - 1] * A[i] // math.gcd(A[i - 1], A[i])
	print(*B)


def gcd(a, b):
	if a % b == 0:
		return b
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def solve(arr):
	new_arr = [1] + arr + [1]
	res = []
	for (a, b) in zip(new_arr, new_arr[1:]):
		res.append(lcm(a, b))
	return res

def main():
	t = int(input())
	for _ in range(t):
		n = input()
		arr = list(map(int, input().split()))
		print(*solve(arr))
main()


from math import gcd

def lcm(x, y):
	return x // gcd(x, y) * y
for _ in range(int(input())):
	n = int(input())
	l = [1] + list(map(int, input().split())) + [1]
	ans = []
	for i in range(1, len(l)):
		ans.append(lcm(l[i], l[i - 1]))
	print(' '.join(map(str, ans)))


t = int(input())
import math
lcm = lambda a, b: a * b // math.gcd(a, b)

def f(a):
	c = [a[0]]
	for i in range(len(a) - 1):
		c.append(lcm(a[i], a[i + 1]))
	c.append(a[-1])
	return c
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = f(a)
	r = [str(e) for e in b]
	print(' '.join(r))


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)
T = int(input().strip())
for t in range(T):
	N = int(input().strip())
	A = [int(x) for x in input().strip().split()]
	B = [A[0]]
	for i in range(N - 1):
		B.append(lcm(A[i], A[i + 1]))
	B.append(A[-1])
	print(*B)


def bitize(x):
	L = []
	while x > 0:
		L.append(x % 2)
		x //= 2
	if not L:
		L = [0]
	return L

def pow_mod(a, b, m):
	b_bits = bitize(b)
	a_powers = [0 for x in b_bits]
	a_powers[0] = a % m
	if b_bits[0]:
		total = a % m
	else:
		total = 1
	for i in range(1, len(b_bits)):
		a_powers[i] = a_powers[i - 1] * a_powers[i - 1] % m
		if b_bits[i]:
			total *= a_powers[i]
			total %= m
	return total

def gcd_matrix(a, b):
	M = [[1, 0, a], [0, 1, b]]
	if a > 0 and b > 0:
		while M[0][2] != 0 and M[1][2] != 0:
			if M[0][2] > M[1][2]:
				multiple = M[0][2] // M[1][2]
				for i in range(0, 3):
					M[0][i] -= multiple * M[1][i]
			elif M[0][2] < M[1][2]:
				multiple = M[1][2] // M[0][2]
				for i in range(0, 3):
					M[1][i] -= multiple * M[0][i]
			elif M[0][2] == M[1][2]:
				return M[0][2]
		if M[0][2] == 0:
			return M[1][2]
		else:
			return M[0][2]
	elif a != 0 and b != 0:
		return gcd_matrix(abs(a), abs(b))
	else:
		return 0

def is_prime(x, L=[]):
	sqrt = int(pow(x, 0.5)) + 1
	PL = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
	if not L:
		if x < 210:
			if x in PL:
				return True
			else:
				return False
		else:
			for p in PL:
				if x % p == 0:
					return False
			for i in range(1, sqrt // 210 + 1):
				for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]:
					if x % (210 * i + j) == 0:
						return False
		return True
	elif x != 0 and x != 1:
		j = 0
		while j < len(L) and L[j] <= sqrt:
			if x % L[j] == 0:
				return False
			j += 1
	else:
		return False
	return True

def is_miller_rabin(x, num_tests=3):
	k = x - 1
	e = 0
	while k % 2 == 0:
		e += 1
		k //= 2
	tests = [False for _ in range(0, num_tests)]
	A = [2, 3, 5]
	for j in range(3, num_tests):
		A.append(random.randint(7, x - 1))
	if x < 2047:
		num_tests = 1
	elif x < 1373653:
		num_tests = 2
	elif x < 25326001:
		num_tests = 3
	for i in range(0, num_tests):
		ak = pow_mod(A[i], k, x)
		if ak == 1:
			tests[i] = True
		else:
			for j in range(0, e):
				if ak == x - 1:
					tests[i] = True
				ak = ak * ak % x
	for i in range(0, num_tests):
		if not tests[i]:
			return False
	return True

def factor(n, PL):
	sqrt = int(pow(n, 0.5)) + 1
	factor_list = []
	if not PL:
		PL = prime_list(sqrt)
	for p in PL:
		if n % p == 0:
			elet = [p, 0]
			while not n % p:
				n //= p
				elet[1] += 1
			factor_list.append(elet)
	if n != 1:
		if is_miller_rabin(n):
			factor_list.append([n, 1])
	return factor_list

def prime_list(n):
	L = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199]
	for k in range(1, n // 210):
		for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]:
			if is_prime(210 * k + j, L):
				L.append(210 * k + j)
	k = n // 210
	for j in [1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209]:
		if is_prime(210 * k + j, L) and 210 * k + j <= n:
			L.append(210 * k + j)
	return L
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	A.append(1)
	B = [0 for x in A]
	B[0] = A[0]
	for i in range(1, len(A)):
		B[i] = A[i] * A[i - 1] // gcd_matrix(A[i], A[i - 1])
	print(' '.join([str(b) for b in B]))


import math
for _ in range(int(input())):
	n = int(input())
	r = [0] * (n + 1)
	l = list(map(int, input().split()))
	for i in range(n):
		r[i + 1] = l[i]
		r[i] = r[i] * l[i] // math.gcd(r[i], l[i])
	r[0] = l[0]
	print(*r)


def gcd(p, q):
	return p if q == 0 else gcd(q, p % q)

def lcm(p, q):
	return p * q // gcd(p, q)
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	l = len(A)
	B = [0] * (l + 1)
	B[0] = A[0]
	for i in range(1, l):
		B[i] = lcm(A[i - 1], A[i])
	B[l] = A[l - 1]
	print(*B)


def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a

def lcm(x):
	return x[0] * x[1] // gcd(x[0], x[1])

def calc(a):
	return list(map(lambda x: lcm(x), list(zip(a + [1], [1] + a))))
for _ in range(int(input())):
	_ = input()
	a = list(map(int, input().strip().split()))
	print(' '.join(list(map(str, calc(a)))))