Vupsen and Pupsen were gifted an integer array. Since Vupsen doesn't like the number 0, he threw away all numbers equal to 0 from the array. As a result, he got an array a of length n.

Pupsen, on the contrary, likes the number 0 and he got upset when he saw the array without zeroes. To cheer Pupsen up, Vupsen decided to come up with another array b of length n such that ∑_{i=1}^{n}a_i ⋅ b_i=0. Since Vupsen doesn't like number 0, the array b must not contain numbers equal to 0. Also, the numbers in that array must not be huge, so the sum of their absolute values cannot exceed 10^9. Please help Vupsen to find any such array b!

Input

The first line contains a single integer t (1 ≤ t ≤ 100) — the number of test cases. The next 2 ⋅ t lines contain the description of test cases. The description of each test case consists of two lines.

The first line of each test case contains a single integer n (2 ≤ n ≤ 10^5) — the length of the array.

The second line contains n integers a_1, a_2, …, a_n (-10^4 ≤ a_i ≤ 10^4, a_i ≠ 0) — the elements of the array a.

It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case print n integers b_1, b_2, …, b_n — elements of the array b (|b_1|+|b_2|+… +|b_n| ≤ 10^9, b_i ≠ 0, ∑_{i=1}^{n}a_i ⋅ b_i=0).

It can be shown that the answer always exists.

Example

Input


3
2
5 5
5
5 -2 10 -9 4
7
1 2 3 4 5 6 7


Output


1 -1
-1 5 1 -1 -1
-10 2 2 -3 5 -1 -1

Note

In the first test case, 5 ⋅ 1 + 5 ⋅ (-1)=5-5=0. You could also print 3 -3, for example, since 5 ⋅ 3 + 5 ⋅ (-3)=15-15=0

In the second test case, 5 ⋅ (-1) + (-2) ⋅ 5 + 10 ⋅ 1 + (-9) ⋅ (-1) + 4 ⋅ (-1)=-5-10+10+9-4=0.

Difficulty: MEDIUM_HARD
Tags: Mathematics

Constructive algorithms

Starter code:

Solutions:
ttt = int(input())
for t in range(ttt):
	n = int(input())
	a = [int(x) for x in input().split()]
	start = 0
	if n % 2 == 1:
		if a[0] + a[1] != 0:
			print(-a[2], -a[2], a[0] + a[1], end=' ')
		elif a[1] + a[2] != 0:
			print(a[2] + a[1], -a[0], -a[0], end=' ')
		else:
			print(-a[1], a[0] + a[2], -a[1], end=' ')
		start = 3
	while start < n:
		print(-a[start + 1], a[start], end=' ')
		start += 2
	print()


import bisect
import collections
import copy
import enum
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(3001)
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 0:
		for i in range(0, n, 2):
			g = math.gcd(abs(arr[i]), abs(arr[i + 1]))
			print(arr[i + 1] // g, end=' ')
			print(-arr[i] // g, end=' ')
	else:
		(a, b, c) = arr[0:3]
		if a + b != 0:
			g = math.gcd(abs(c), abs(a + b))
			print(-c // g, end=' ')
			print(-c // g, end=' ')
			print((a + b) // g, end=' ')
		elif a + c != 0:
			g = math.gcd(abs(b), abs(a + c))
			print(-b // g, end=' ')
			print((a + c) // g, end=' ')
			print(-b // g, end=' ')
		elif b + c != 0:
			g = math.gcd(abs(a), abs(c + b))
			print((b + c) // g, end=' ')
			print(-a // g, end=' ')
			print(-a // g, end=' ')
		for i in range(3, n, 2):
			g = math.gcd(abs(arr[i]), abs(arr[i + 1]))
			print(arr[i + 1] // g, end=' ')
			print(-arr[i] // g, end=' ')
	print()


import sys
import math
import random
import heapq
input = sys.stdin.readline

def pow(a, n, m):
	if n == 0:
		return 1
	x = pow(a, n // 2, m)
	if n % 2 == 0:
		return x * x % m
	else:
		return x * x * a % m

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

def bs(arr, le, ri):
	l = 0
	arr.sort()
	r = len(arr) - 1
	ans = 10000000
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= le and arr[m] <= ri:
			ans = arr[m]
			r = m - 1
		elif arr[m] < le:
			l = m + 1
		else:
			r = m - 1
	return ans
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	b = [1] * n
	s = a[0]
	for i in range(1, n):
		if s * a[i] > 0:
			b[i] = -1
			s -= a[i]
		else:
			s += a[i]
	if s != 0:
		c = 100000
		ind = -1
		for i in range(n):
			if s - a[i] * b[i] != 0 and abs(s - a[i] * b[i]) < c:
				c = a[i] * b[i]
				ind = i
		for i in range(n):
			if i == ind:
				b[i] *= s - c
			else:
				b[i] *= -1 * c
	print(' '.join(map(str, b)))
	s = 0
	c = 0
	for i in range(n):
		c += abs(b[i])
		s += a[i] * b[i]
	if c > 1000000000:
		while True:
			pass
	t -= 1


for fghn in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			if a[i] / abs(a[i]) == 1:
				b.append(abs(a[i + 1]))
			else:
				b.append(abs(a[i + 1]) * -1)
			if a[i + 1] / abs(a[i + 1]) == 1:
				b.append(-1 * abs(a[i]))
			else:
				b.append(abs(a[i]))
	else:
		if a[0] / abs(a[0]) == 1:
			b.append(abs(a[2]))
		else:
			b.append(-abs(a[2]))
		if a[1] / abs(a[1]) == 1:
			b.append(abs(a[2]))
		else:
			b.append(-abs(a[2]))
		if a[2] / abs(a[2]) == 1:
			b.append(-abs(a[1]) - abs(a[0]))
		else:
			b.append(abs(a[1]) + abs(a[0]))
		for i in range(3, n, 2):
			if a[i] / abs(a[i]) == 1:
				b.append(abs(a[i + 1]))
			else:
				b.append(abs(a[i + 1]) * -1)
			if a[i + 1] / abs(a[i + 1]) == 1:
				b.append(-1 * abs(a[i]))
			else:
				b.append(abs(a[i]))
	for i in b:
		print(i, end=' ')
	print()


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if n % 2 == 1:
		for i in range(1, n - 1, 2):
			ans += [arr[i]]
			ans += [arr[i - 1] * -1]
		temp = ans[n - 2] + -1 * arr[n - 1]
		if temp != 0:
			ans[n - 2] += -1 * arr[n - 1]
			ans += [arr[n - 2]]
		else:
			ans[n - 2] += arr[n - 1]
			ans += [arr[n - 2] * -1]
	else:
		for i in range(1, n, 2):
			ans += [arr[i]]
			ans += [arr[i - 1] * -1]
	for pp in ans:
		print(pp, end=' ')
	print()


import sys
input = sys.stdin.readline
t = int(input())
for __ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(0, n - 3, 2):
		(n1, n2) = (arr[i], arr[i + 1])
		if n1 * n2 > 0:
			print(-n2, n1, end=' ')
		else:
			print(-n2, n1, end=' ')
	if n % 2 == 0:
		(n1, n2) = (arr[-2], arr[-1])
		if n1 * n2 > 0:
			print(-n2, n1, end=' ')
		else:
			print(-n2, n1, end=' ')
	else:
		(n1, n2, n3) = (arr[-3], arr[-2], arr[-1])
		if n1 + n2 != 0:
			(n1, n2) = (n1 + n2, n3)
			if n1 * n2 > 0:
				print(-n2, -n2, n1, end='')
			else:
				print(n2, n2, -n1, end='')
		elif n1 + n3 != 0:
			(n1, n2) = (n1 + n3, n2)
			if n1 * n2 > 0:
				print(-n2, n1, -n2, end='')
			else:
				print(n2, -n1, n2, end='')
		elif n2 + n3 != 0:
			(n1, n2) = (n1, n2 + n3)
			if n1 * n2 > 0:
				print(n2, -n1, -n1, end='')
			else:
				print(-n2, n1, n1, end='')
	print()


import sys
from functools import lru_cache
from collections import defaultdict, deque
from types import GeneratorType
input = sys.stdin.readline

def sign(num):
	return 1 if num > 0 else -1

def solve(nums):
	n = len(nums)
	coeffs = [0] * n
	right_sum = 0
	for i in range(1, n):
		if right_sum > 0:
			coeffs[i] = -1 * sign(nums[i])
			right_sum -= abs(nums[i])
		else:
			coeffs[i] = 1 * sign(nums[i])
			right_sum += abs(nums[i])
	if right_sum == 0:
		coeffs[1] += abs(nums[0]) * sign(coeffs[1])
		if nums[1] > 0:
			coeffs[0] = -abs(nums[1]) * sign(nums[0])
		else:
			coeffs[0] = -abs(nums[1]) * sign(nums[0])
	else:
		for i in range(1, n):
			coeffs[i] *= abs(nums[0])
		if right_sum > 0:
			coeffs[0] = -abs(right_sum) * sign(nums[0])
		else:
			coeffs[0] = abs(right_sum) * sign(nums[0])
	sys.stdout.write(' '.join(map(str, coeffs)) + '\n')
t = int(input())
for _ in range(t):
	_ = input()
	nums = [int(num) for num in input().split()]
	solve(nums)


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
inp_vars_int = lambda : map(int, input().split())
inp_list_int = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	_ = int(input())
	a = inp_list_int()
	n = len(a)
	a_s = sorted(enumerate(a), key=lambda x: x[1])
	min_diff = math.inf
	i_d = None
	for i in range(1, n):
		diff = a_s[i][1] - a_s[i - 1][1]
		if 0 < diff < min_diff:
			i_d = i
			min_diff = diff
	cs = 0
	if min_diff in (math.inf, 0):
		b = [1] * (n - 1) + [1 - n]
	else:
		b = [None for _ in range(len(a))]
		(d2, d1) = (a_s[i_d][0], a_s[i_d - 1][0])
		for (i, ai) in enumerate(a):
			if i in (d1, d2):
				continue
			sig = (cs > 0) == (ai > 0)
			bi = (1 - 2 * sig) * min_diff
			b[i] = bi
			cs += bi * ai
		mult = cs // min_diff
		if mult != 0:
			(b[d2], b[d1]) = (-mult, mult)
		else:
			(a2, a1) = (a[d2], a[d1])
			(b[d2], b[d1]) = (a1 * math.gcd(a2, a1), -a2 * math.gcd(a2, a1))
	print(*b)


import sys
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = [0] * n
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				B[i] = A[i + 1]
			else:
				B[i] = -A[i - 1]
	else:
		if A[0] + A[1] != 0:
			B[0] = -A[2]
			B[1] = -A[2]
			B[2] = A[0] + A[1]
		elif A[1] + A[2] != 0:
			B[0] = A[1] + A[2]
			B[1] = -A[0]
			B[2] = -A[0]
		else:
			B[0] = -A[1]
			B[1] = A[0] + A[2]
			B[2] = -A[1]
		for i in range(3, n):
			a = A[i]
			if i % 2 == 1:
				B[i] = A[i + 1]
			else:
				B[i] = -A[i - 1]
	print(*B)


from collections import Counter, deque
import math
from random import randint
from bisect import bisect
import sys
import re
import copy
MOD = 1000000007
MAX = sys.maxsize
MIN = -sys.maxsize
value = {}

class get:

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

	def str():
		return input().split()

	def float():
		return list(map(float, input().split()))

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

def sqrt(x):
	return int(math.sqrt(x)) + 1

def gcd(*args):
	result = args[0]
	for item in args:
		result = math.gcd(result, item)
	return result

def LCM(a, b):
	return a * b // math.gcd(a, b)

def three(a, b, c):
	if a + b != 0:
		return (c, c, -(a + b))
	elif b + c != 0:
		return (-(b + c), a, a)
	else:
		return (b, -(a + c), b)

def solve():
	n = int(input())
	a = get.int()
	b = [0] * n
	if n % 2 == 0:
		for i in range(0, n, 2):
			if a[i] * a[i + 1] < 0:
				(b[i], b[i + 1]) = (abs(a[i + 1]), abs(a[i]))
			else:
				b[i] = a[i + 1]
				b[i + 1] = -a[i]
		print(*b)
	else:
		for i in range(0, n - 3, 2):
			if a[i] * a[i + 1] < 0:
				(b[i], b[i + 1]) = (abs(a[i + 1]), abs(a[i]))
			else:
				b[i] = a[i + 1]
				b[i + 1] = -a[i]
		(b[n - 3], b[n - 2], b[n - 1]) = three(a[n - 3], a[n - 2], a[n - 1])
		print(*b)
for _ in range(int(input())):
	solve()


import sys, os, io
import math
import bisect
t = int(input())
for a0 in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	res = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			res.append(-1 * l[i + 1])
			res.append(l[i])
		print(*res)
	else:
		if l[0] + l[1] != 0:
			a = l[0] + l[1]
			res = [l[2], l[2], -1 * a]
		elif l[1] + l[2] != 0:
			a = l[1] + l[2]
			res = [-1 * a, l[0], l[0]]
		else:
			a = l[0] + l[2]
			res = [l[1], -1 * a, l[1]]
		for i in range(3, n, 2):
			res.append(-1 * l[i + 1])
			res.append(l[i])
		print(*res)


import sys, math

def lcm(x, y):
	(x, y) = (abs(x), abs(y))
	return x * y // math.gcd(x, y)
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	for i in range((n - 2 if n % 2 else n) // 2):
		(x, y) = (a[i + i], a[i + i + 1])
		l = lcm(x, y)
		if x * y < 0:
			sys.stdout.write('%d %d ' % (l // abs(x), l // abs(y)))
		else:
			sys.stdout.write('%d %d ' % (l // x, -l // y))
	if n % 2:
		(x, y, z) = (a[-3], a[-2], a[-1])
		(l1, l2) = (lcm(x, z), lcm(y, z))
		sys.stdout.write('%d %d %d\n' % (l1 // x, l2 // y, -(l1 + l2) // z))
	else:
		sys.stdout.write('\n')


from collections import defaultdict
from queue import PriorityQueue, Queue
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = [0] * n
	if n % 2 == 0:
		for i in range(0, n, 2):
			res[i] = -a[i + 1]
			res[i + 1] = a[i]
	else:
		for i in range(0, n - 1, 2):
			res[i] = -a[i + 1]
			res[i + 1] = a[i]
		if a[n - 1] != a[1]:
			res[0] += a[n - 1]
			res[n - 1] = -a[0]
		else:
			res[0] -= a[n - 1]
			res[n - 1] = a[0]
	print(' '.join((str(i) for i in res)))


import os
import sys
from io import BytesIO, IOBase
_str = str
str = lambda x=b'': x if type(x) is bytes else _str(x).encode()
BUFSIZE = 8192

def sigma1(a):
	return sum(a)

def sigma2(a):
	return sum([i * i for i in a])

def sigma3(a):
	return sum([i * i * i for i in a])

def prodofpairs(a):
	return (sigma1(a) ** 2 - sigma2(a)) // 2

def prodoftriplets(a):
	return (sigma1(a) ** 3 - 3 * sigma1(a) * sigma2(a) + 2 * sigma3(a)) // 6
from collections import Counter, defaultdict
from math import gcd
from collections import deque

def bfs(graph, start=0):
	used = [False] * len(graph)
	used[start] = True
	q = [start]
	for v in q:
		for w in graph[v]:
			if not used[w]:
				used[w] = True
				q.append(w)

def layers(graph, start=0):
	used = [False] * len(graph)
	used[start] = True
	(q, ret) = ([start], [])
	level = [0] * len(graph)
	while q:
		nq = []
		ret.append(q)
		for v in q:
			for w in graph[v]:
				if not used[w]:
					used[w] = True
					nq.append(w)
					level[w] = 1 + level[v]
		q = nq
	return level
import math

def findMaxGCD(arr, n, k):
	high = max(arr)
	divisors = [0] * (high + 1)
	for i in range(n):
		for j in range(1, int(math.sqrt(arr[i])) + 1):
			if arr[i] % j == 0:
				divisors[j] += 1
				if j != arr[i] // j:
					divisors[arr[i] // j] += 1
	for i in range(high, 0, -1):
		if divisors[i] >= k:
			return i

def xdist(a, b):
	if b[0] >= a[0] >= b[2] or b[0] <= a[0] <= b[2]:
		return 0
	return min(abs(a[0] - b[0]), abs(a[0] - b[2]))

def ydist(a, b):
	if b[1] >= a[1] >= b[3] or b[1] <= a[1] <= b[3]:
		return 0
	return min(abs(a[1] - b[1]), abs(a[1] - b[3]))

def countdistx(i, j, k, obj):
	m = 0
	for i1 in range(k):
		m += xdist([i, j], obj[i1])
	return m

def countdisty(i, j, k, obj):
	m = 0
	for i1 in range(k):
		m += ydist([i, j], obj[i1])
	return m
from bisect import bisect_left

def dp(i, n, cost, a):
	if cost == 0:
		return 0
	if cost < 0:
		return float('Inf')
	l = [float('Inf')]
	for j in range(i, n + 1):
		k = bisect_left(a, a[j] + cost, j)
		if k <= n and a[k] == a[j] + cost:
			l.append(k - j)
	return min(l)

def isp(x):
	for i in range(2, int(math.sqrt(x)) + 1):
		if x % i == 0:
			return False
	return True
from bisect import bisect_right
from sys import stdout

def sol(s, c, i, j):
	a = s
	count = 0
	while i < j:
		if a[i] == a[j]:
			i += 1
			j -= 1
		elif a[i] == c:
			i += 1
			count += 1
		elif a[j] == c:
			j -= 1
			count += 1
		else:
			return -1
	return count

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		s = 0
		m = abs(min(a, key=lambda x: abs(x)))
		x = 0
		l = [1] * n
		for i in range(n):
			if i % 2 == 0:
				l[i] = 1
				s += a[i]
			else:
				s -= a[i]
				l[i] = -1
		for i in range(n):
			if i % 2 == 0 and s - a[i] != 0:
				l[i] = -(s - a[i])
				for j in range(n):
					if i != j:
						l[j] = l[j] * a[i]
				print(*l)
				break
			elif i % 2 == 1 and s + a[i] != 0:
				l[i] = -(s + a[i])
				for j in range(n):
					if i != j:
						l[j] = l[j] * a[i]
				print(*l)
				break
main()

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')


import sys
input = lambda : sys.stdin.readline().rstrip()
import bisect
import itertools
import math
from collections import deque
from collections import Counter
INF = 10 ** 18
import copy
import string
import random

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	now = 0
	while now < n:
		if now + 3 == n:
			if a[-3] + a[-2] == 0:
				if a[-1] + 1 != 0:
					y1 = a[-1] + 1
					y2 = 1
					y3 = -a[-3]
				else:
					y1 = a[-1] - 1
					y2 = -1
					y3 = -a[-3]
			else:
				y1 = a[-1]
				y2 = a[-1]
				y3 = -a[-3] - a[-2]
			b.append(y1)
			b.append(y2)
			b.append(y3)
			now = n
		else:
			b.append(-a[now + 1])
			b.append(a[now])
			now += 2
	s = 0
	su = 0
	for i in range(n):
		s += a[i] * b[i]
		su += abs(b[i])
	if s != 0 or su > 10 ** 9 or 0 in b:
		print(b[-1], b[-2], b[-3])
		print(s, su, 0 in b)
		raise Exception
	else:
		print(*b)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			ans.append(-a[i + 1])
			ans.append(a[i])
		print(*ans)
	else:
		for i in range(0, n - 3, 2):
			ans.append(-a[i + 1])
			ans.append(a[i])
		q = a[len(a) - 1]
		w = a[len(a) - 2]
		e = a[len(a) - 3]
		if q + w != 0:
			l = q
			h = w
			j = e
			ans.append(-(l + h))
			ans.append(e)
			ans.append(e)
		elif q + e != 0:
			l = q
			h = e
			j = w
			ans.append(w)
			ans.append(-(l + h))
			ans.append(w)
		elif e + w != 0:
			l = w
			h = e
			j = q
			ans.append(j)
			ans.append(j)
			ans.append(-(l + h))
		print(*ans)


t = int(input())
for h in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	if n % 2 == 0:
		for k in range(0, n, 2):
			print(A[k + 1], -A[k], end=' ')
		print('')
	else:
		a = 1
		c = A[-1]
		x = A[-2]
		z = A[-3]
		if A[-1] == A[-2]:
			if A[-2] == A[-3]:
				a = 3
			else:
				a = 2
		for k in range(0, n - 3, 2):
			print(A[k + 1], -A[k], end=' ')
		if a == 1:
			print(x - c, -z, z)
		elif a == 2:
			print(x, c - z, -x)
		elif a == 3:
			print(-2 * x, x, x)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	li = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			li.append(a[i + 1])
			li.append(-a[i])
	else:
		for i in range(0, n - 3, 2):
			li.append(a[i + 1])
			li.append(-a[i])
		if a[-2] + a[-3] != 0:
			li.append(-a[-1])
			li.append(-a[-1])
			li.append(a[-2] + a[-3])
		elif a[-1] + a[-3] != 0:
			li.append(-a[-2])
			li.append(a[-1] + a[-3])
			li.append(-a[-2])
		elif a[-2] + a[-1] != 0:
			li.append(a[-2] + a[-1])
			li.append(-a[-3])
			li.append(-a[-3])
	print(*li)


import sys, os, io
input = sys.stdin.readline
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 = [0 for i in range(n)]
	if n % 2 == 0:
		l = 0
		r = n - 1
		while l < r:
			g = gcd(abs(a[l]), abs(a[r]))
			x = a[l] // g
			y = a[r] // g
			b[l] = -y
			b[r] = x
			l += 1
			r -= 1
		c = [a[i] * b[i] for i in range(n)]
		print(*b)
	else:
		x = 0
		y = -1
		for i in range(1, n):
			if a[i] + a[x] != 0 and i != x:
				y = i
				break
		if y == -1:
			x = 1
			for i in range(n):
				if a[i] + a[x] != 0 and i != x:
					y = i
					break
		z = -1
		for i in range(n):
			if i != x and i != y:
				xx = a[x] + a[y]
				yy = a[i]
				g = gcd(abs(xx), abs(yy))
				xx //= g
				yy //= g
				b[i] = -xx
				b[x] = yy
				b[y] = yy
				break
		l = 0
		r = n - 1
		while l < r:
			if b[l] != 0:
				l += 1
				continue
			if b[r] != 0:
				r -= 1
				continue
			g = gcd(abs(a[l]), abs(a[r]))
			x = a[l] // g
			y = a[r] // g
			b[l] = -y
			b[r] = x
			l += 1
			r -= 1
		c = [a[i] * b[i] for i in range(n)]
		print(*b)


def rest(arr):
	r = []
	for (a, b) in arr:
		r += [-b, a]
	return r

def signum(x):
	return 1 if x > 0 else -1
for _ in range(int(input())):
	input()
	a = [int(x) for x in input().split()]
	c = [a[i:i + 2] for i in range(0, len(a), 2)]
	if len(c[-1]) == 1:
		alone = c[-1][0]
		twos = -1 * (abs(c[-2][0]) + abs(c[-2][1]))
		print(*rest(c[:-2]) + [alone * signum(c[-2][0]), alone * signum(c[-2][1]), twos])
	else:
		print(*rest(c))


T = int(input())
for t in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		i = 0
		while i < n:
			ans.extend([-arr[i + 1], arr[i]])
			i += 2
	else:
		i = 0
		while i < n - 3:
			ans.extend([-arr[i + 1], arr[i]])
			i += 2
		(a, b, c) = (arr[-3], arr[-2], arr[-1])
		if a == b == c:
			ans.extend([-2, 1, 1])
		elif a == b:
			ans.extend([c, c, -2 * a])
		elif b == c:
			ans.extend([-2 * b, a, a])
		elif a == c:
			ans.extend([b, -2 * a, b])
		else:
			ans.extend([b - c, c - a, a - b])
	print(*ans)


import sys
readline = sys.stdin.readline
T = int(readline())
for t in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	B = [0] * N
	for i in range(N // 2):
		B[2 * i] += A[2 * i + 1]
		B[2 * i + 1] -= A[2 * i]
	if N % 2:
		if A[N - 3] == A[N - 1]:
			B[N - 2] -= A[N - 1]
			B[N - 1] += A[N - 2]
		else:
			B[N - 2] += A[N - 1]
			B[N - 1] -= A[N - 2]
	print(*B)


import random
import sys

def input():
	return sys.stdin.readline().strip('\n')

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

def cin_int():
	return int(input())
import math

def check(s, ans):
	cc = 0
	for i in range(len(s)):
		cc += s[i] * ans[i]
	print(cc == 0 and 0 not in ans, cc)

def sv(s):
	ans = [0 for _ in s]
	if len(s) % 2 == 0:
		for i in range(len(s) // 2):
			(a, b) = (s[i], s[-i - 1])
			gcd = math.gcd(a, b)
			(aa, bb) = (b // gcd, a // gcd)
			ans[i] = aa
			ans[-i - 1] = -bb
		return ans
	else:
		for i in range(len(s) // 2 - 1):
			(a, b) = (s[i], s[-i - 1])
			gcd = math.gcd(a, b)
			(aa, bb) = (b // gcd, a // gcd)
			ans[i] = aa
			ans[-i - 1] = -bb
		(mid1, mid2, mid3) = (len(s) // 2 - 1, len(s) // 2, len(s) // 2 + 1)
		(a, b, c) = (s[mid1], s[mid2], s[mid3])
		if a + b != 0:
			(a, b) = (a + b, c)
			(mid1, mid2, mid3) = (mid1, mid2, mid3)
		elif a + c != 0:
			(a, b) = (a + c, b)
			(mid1, mid2, mid3) = (mid1, mid3, mid2)
		elif c + b != 0:
			(a, b) = (b + c, a)
			(mid1, mid2, mid3) = (mid2, mid3, mid1)
		gcd = math.gcd(a, b)
		(aa, bb) = (b // gcd, a // gcd)
		ans[mid1] = aa
		ans[mid2] = aa
		ans[mid3] = -bb
		return ans

def main():
	for _ in range(cin_int()):
		cin_int()
		s = cin_int_ls()
		ans = sv(s)
		print(*ans)
main()


def solve_case():
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	i = -2
	j = -1
	if n % 2 == 0:
		for p in range(n // 2):
			i = 2 * p
			j = 2 * p + 1
			b[i] = a[j]
			b[j] = -a[i]
	else:
		for p in range(n // 2 - 1):
			i = 2 * p
			j = 2 * p + 1
			b[i] = a[j]
			b[j] = -a[i]
		i += 2
		p = -1
		q = -1
		if a[i] + a[i + 1] != 0:
			p = i
			q = i + 1
			r = i + 2
		elif a[i] + a[i + 2] != 0:
			p = i
			q = i + 2
			r = i + 1
		else:
			p = i + 1
			q = i + 2
			r = i
		b[r] = a[p] + a[q]
		b[p] = b[q] = -a[r]
	print(' '.join(map(str, b)))
T = int(input())
for t in range(T):
	solve_case()


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	if s == 0:
		ans = [1] * n
		print(*ans)
	else:
		arr = []
		if n % 2 == 0:
			for i in range(0, n, 2):
				arr.append(-a[i + 1])
				arr.append(a[i])
			print(*arr)
		elif a[0] + a[1] != 0:
			arr = [-a[2], -a[2], a[0] + a[1]]
			for i in range(3, n, 2):
				arr.append(-a[i + 1])
				arr.append(a[i])
			print(*arr)
		elif a[1] + a[2] != 0:
			arr = [a[1] + a[2], -a[0], -a[0]]
			for i in range(3, n, 2):
				arr.append(-a[i + 1])
				arr.append(a[i])
			print(*arr)
		else:
			arr = [-a[1], a[0] + a[2], -a[1]]
			for i in range(3, n, 2):
				arr.append(-a[i + 1])
				arr.append(a[i])
			print(*arr)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	b = [0] * n
	i = 0
	j = n - 1
	while i < j:
		b[i] = -l[j]
		b[j] = l[i]
		i += 1
		j -= 1
	if n % 2:
		if b[i - 1] < 0 and l[i] > 0 or (b[i - 1] > 0 and l[i] < 0):
			b[i] = l[i - 1]
			b[i - 1] -= l[i]
		else:
			b[i] = -l[i - 1]
			b[i - 1] += l[i]
	print(*b)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	smallest = float('inf')
	chosen_index = -1
	for i in range(n):
		if abs(l[i]) < smallest:
			smallest = abs(l[i])
			chosen_index = i
	sum1 = 0
	b = [0 for j in range(n)]
	for i in range(n):
		if i != chosen_index:
			if sum1 <= 0:
				if l[i] > 0:
					b[i] = smallest
					sum1 += abs(smallest * l[i])
				else:
					b[i] = -smallest
					sum1 += abs(smallest * l[i])
			elif l[i] > 0:
				b[i] = -smallest
				sum1 -= abs(smallest * l[i])
			else:
				b[i] = smallest
				sum1 -= abs(smallest * l[i])
	if sum1 == 0:
		if chosen_index != 0:
			if b[0] == smallest:
				b[0] = -smallest
			else:
				b[0] = smallest
			sum1 = -2 * abs(l[0] * b[0])
			b[chosen_index] = -(sum1 // l[chosen_index])
		else:
			if b[-1] * l[-1] > 0:
				sum1 = -2 * abs(b[-1] * l[-1])
			else:
				sum1 = 2 * abs(b[-1] * l[-1])
			if b[-1] > 0:
				b[-1] = -b[-1]
			else:
				b[-1] = abs(b[-1])
			b[0] = -(sum1 // l[0])
	else:
		b[chosen_index] = -(sum1 // l[chosen_index])
	print(*b)


for _ in range(int(input())):
	lx = int(input())
	x = list(map(int, input().split()))
	if lx & 1:
		(a, b, c) = x[:3]
		if a + b != 0:
			print('{} {} {}'.format(-c, -c, a + b), end='')
		elif c + a != 0:
			print('{} {} {}'.format(-b, c + a, -b), end='')
		else:
			print('{} {} {}'.format(b + c, -a, -a), end='')
		for i in range(3, lx, 2):
			print(' {} {}'.format(x[i + 1], -x[i]), end='')
		print()
	else:
		for i in range(0, lx, 2):
			print('{} {}'.format(x[i + 1], -x[i]), end='')
			if lx - i > 2:
				print(' ', end='')
		print()


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

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

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	ans = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			if arr[i] > 0 and arr[i + 1] > 0 or (arr[i] < 0 and arr[i + 1] < 0):
				ans.append(arr[i + 1])
				ans.append(-arr[i])
			else:
				ans.append(abs(arr[i + 1]))
				ans.append(abs(arr[i]))
	else:
		for i in range(0, n - 3, 2):
			if arr[i] > 0 and arr[i + 1] > 0 or (arr[i] < 0 and arr[i + 1] < 0):
				ans.append(arr[i + 1])
				ans.append(-arr[i])
			else:
				ans.append(abs(arr[i + 1]))
				ans.append(abs(arr[i]))
		ans.append(arr[-1])
		ans.append(arr[-1] * 2)
		diff = arr[-3] * arr[-1] + arr[-2] * arr[-1] * 2
		ch = -(diff // arr[-1])
		ans.append(ch)
	print(*ans)


testcase = int(input())
for test in range(0, testcase):
	n = int(input())
	a = list(map(int, input().split()))
	b = list()
	if n % 2 == 0:
		for i in range(0, n, 2):
			b.append(-1 * a[i + 1])
			b.append(a[i])
	else:
		for i in range(0, n - 3, 2):
			b.append(-1 * a[i + 1])
			b.append(a[i])
		if a[-3] + a[-2] != 0:
			b.append(-1 * a[-1])
			b.append(-1 * a[-1])
			b.append(a[-2] + a[-3])
		elif a[-2] + a[-1] != 0:
			b.append(a[-1] + a[-2])
			b.append(-1 * a[-3])
			b.append(-1 * a[-3])
		elif a[-1] + a[-3] != 0:
			b.append(-1 * a[-2])
			b.append(a[-1] + a[-3])
			b.append(-1 * a[-2])
	print(*b)


import sys, math
input = sys.stdin.readline
INF = int(1000000000.0) + 7
base = [chr(i) for i in range(97, 123)]

def solve():
	n = int(input())
	data = list(map(int, input().split()))
	data = [(data[i], i) for i in range(n)]
	data.sort()
	result = [0] * n
	if n % 2 == 0:
		for i in range(0, n, 2):
			result[data[i][1]] = data[i + 1][0]
			result[data[i + 1][1]] = -data[i][0]
		print(*result, sep=' ')
	else:
		if data[0][0] != data[2][0]:
			result[data[0][1]] = data[1][0]
			result[data[1][1]] = data[2][0] - data[0][0]
			result[data[2][1]] = -data[1][0]
		else:
			result[data[0][1]] = 2
			result[data[1][1]] = -1
			result[data[2][1]] = -1
		for i in range(3, n, 2):
			result[data[i][1]] = data[i + 1][0]
			result[data[i + 1][1]] = -data[i][0]
		print(*result, sep=' ')
t = int(input())
while t:
	t -= 1
	solve()


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	n_ = n
	if n % 2 == 1:
		n_ = n - 1
	for i in range(0, n - 1, 2):
		ai = a[i]
		ai1 = a[i + 1]
		g = math.gcd(ai, ai1)
		b.append(int(-ai1 / g))
		b.append(int(ai / g))
	if n % 2 == 1:
		b.pop()
		b.pop()
		b3 = a[n - 3] + a[n - 2]
		add = 1
		if b3 == 0:
			b3 = a[n - 3]
			add = 2
		b1 = -a[n - 1] * add
		b2 = -a[n - 1]
		b.append(b1)
		b.append(b2)
		b.append(b3)
	[print(x, end=' ') for x in b]
	print()


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	for j in range(n // 2):
		b[j] = a[n - 1 - j]
		b[n - 1 - j] = -a[j]
	if n % 2:
		if a[n // 2] + a[n // 2 - 1] == 0:
			b[n // 2 - 1] = a[n // 2 + 1]
			b[n // 2] = -a[n // 2 + 1]
			b[n // 2 + 1] = -(-a[n // 2] + a[n // 2 - 1])
		else:
			b[n // 2 - 1] = b[n // 2] = a[n // 2 + 1]
			b[n // 2 + 1] = -(a[n // 2] + a[n // 2 - 1])
	print(' '.join((str(x) for x in b)))


case = int(input())
for i in range(case):
	n = int(input())
	L = list(map(int, input().split()))
	LL = [[L[i], i] for i in range(n)]
	LL.sort(key=lambda x: abs(x[0]))
	LL.reverse()
	L_ans = [0] * n
	ssum = 0
	for j in LL:
		if ssum * j[0] > 0:
			ssum -= j[0]
			L_ans[j[1]] = -1
		else:
			ssum += j[0]
			L_ans[j[1]] = 1
	if ssum == 0:
		LS = [str(j) for j in L_ans]
		print(' '.join(LS))
	elif L_ans[0] * L[0] != ssum:
		LS = [str(j * L[0]) for j in L_ans]
		LS[0] = str(int(LS[0]) - ssum)
		print(' '.join(LS))
	else:
		LS = [str(j * L[0]) for j in L_ans]
		LS[0] = str(int(LS[0]) - ssum)
		LS[0] = str(int(LS[0]) + L[1])
		LS[1] = str(int(LS[1]) - L[0])
		if LS[1] == '0':
			LS[0] = str(int(LS[0]) + L[1])
			LS[1] = str(int(LS[1]) - L[0])
		print(' '.join(LS))


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
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')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	cnt = []
	while n % 2 == 0:
		cnt.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt.append(i)
			n = n / i
	if n > 2:
		cnt.append(int(n))
	return cnt

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def inv(n, m):
	return pow(n, m - 2, m)
for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			(x, y) = (l[i], l[i + 1])
			ans += [-y, x]
	else:
		l1 = [l[0], l[1], l[2]]
		if l[1] + l[2] != 0:
			l2 = [l[1] + l[2], -l[0], -l[0]]
		elif l[0] + l[1] != 0:
			l2 = [-l[2], -l[2], l[0] + l[1]]
		else:
			l2 = [-l[1], l[0] + l[2], -l[1]]
		ans += l2
		for i in range(3, n, 2):
			(x, y) = (l[i], l[i + 1])
			ans += [-y, x]
	print(*ans)
	s = 0
	for i in range(0, n):
		s += l[i] * ans[i]


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	ans = []
	while len(A) > 3:
		a = A.pop()
		b = A.pop()
		ans.append(-b)
		ans.append(a)
	if len(A) == 2:
		a = A.pop()
		b = A.pop()
		ans.append(-b)
		ans.append(a)
	else:
		(x, y, z) = A
		if x + y != 0:
			ans.append(-x - y)
			ans.append(z)
			ans.append(z)
		else:
			ans.append(-x + y)
			ans.append(-z)
			ans.append(z)
	ans.reverse()
	print(*ans)
	tmp = 0


import os, sys
from io import BytesIO, IOBase
from math import log2, ceil, sqrt, gcd
from _collections import deque
import heapq as hp
from bisect import bisect_left, bisect_right
from math import cos, sin
from itertools import permutations
from operator import itemgetter
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')
pi = 3.1415926535
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n & 1 == 0:
		for i in range(0, n, 2):
			print(a[i + 1], -a[i], end=' ')
		print()
	else:
		d = dict()
		id = 0
		for i in a:
			d[i] = d.get(i, 0) + 1
			if d[i] >= 3:
				id = i
				break
		if id != 0:
			s = set(list(range(n)))
			ck = []
			for i in range(n):
				if a[i] == id:
					s.remove(i)
					ck.append(i)
					if len(ck) == 3:
						break
			ans = [0] * n
			while s:
				x = s.pop()
				y = s.pop()
				ans[x] = a[y]
				ans[y] = -a[x]
			ans[ck[0]] = 1
			ans[ck[1]] = 1
			ans[ck[2]] = -2
			print(*ans)
		else:
			ck = list(range(n))
			ck.sort(key=lambda x: abs(a[x]))
			ans = [0] * n
			for i in range(3):
				if a[ck[i]] + a[ck[(i + 1) % 3]] == 0:
					continue
				x = a[ck[i]] + a[ck[(i + 1) % 3]]
				y = a[ck[(i + 2) % 3]]
				ans[ck[(i + 2) % 3]] = -x
				ans[ck[i]] = y
				ans[ck[(i + 1) % 3]] = y
				break
			for i in range(3, n, 2):
				ans[ck[i]] = a[ck[i + 1]]
				ans[ck[i + 1]] = -a[ck[i]]
			print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input().split())
	for i in range(n):
		s[i] = int(s[i])
	m = n
	if n % 2 != 0:
		n = n - 3
	for j in range(n // 2):
		print(-s[n - j - 1], end=' ')
	for j in range(n // 2, n - 1):
		print(s[n - j - 1], end=' ')
	if m % 2 == 0:
		print(s[0])
	else:
		if n > 0:
			print(s[0], end=' ')
		if s[n + 1] + s[n + 2] != 0:
			print(-(s[n + 1] + s[n + 2]), end=' ')
			print(s[n], s[n])
		elif s[n] + s[n + 1] != 0:
			print(-s[n + 2], -s[n + 2], end=' ')
			print(s[n] + s[n + 1])
		else:
			print(-s[n + 1], s[n] + s[n + 2], -s[n + 1])


def main():
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	inf = 1e+17
	mod = 10 ** 9 + 7

	def factorial(n):
		f = 1
		for i in range(1, n + 1):
			f = f * i % mod
		return f

	def factorial_by(n, by):
		f = 1
		for i in range(1, n + 1):
			if i == by:
				continue
			f = f * i % mod
		return f

	def ncr(n, r):
		num = den = 1
		for i in range(r):
			num = num * (n - i) % mod
			den = den * (i + 1) % mod
		return num * pow(den, mod - 2, mod) % mod

	def primeFactors(num):
		pf = []
		while num % 2 == 0:
			pf.append(2)
			num = num // 2
		for i in range(3, int(math.sqrt(num)) + 1, 2):
			while num % i == 0:
				pf.append(i)
				num = num // i
		if num > 2:
			pf.append(num)
		return pf

	class Node(object):

		def __init__(self, name, d):
			self.d = d
			self.name = name

		def __repr__(self):
			pass

	def solve(n, a):
		if n % 2:
			b = []
			for i in range(0, n - 3, 2):
				b.append(-a[i + 1])
				b.append(a[i])
			b.append(0)
			b.append(0)
			b.append(0)
			if a[n - 3] != a[n - 2]:
				b[n - 3] = -a[n - 1]
				b[n - 2] = a[n - 1]
				b[n - 1] = a[n - 3] - a[n - 2]
			elif a[n - 3] != a[n - 1]:
				b[n - 3] = -a[n - 2]
				b[n - 2] = a[n - 3] - a[n - 1]
				b[n - 1] = a[n - 2]
			elif a[n - 1] != a[n - 2]:
				b[n - 3] = a[n - 2] - a[n - 1]
				b[n - 2] = -a[n - 3]
				b[n - 1] = a[n - 3]
			else:
				b[n - 3] = 1
				b[n - 2] = 1
				b[n - 1] = -2
			return ' '.join(list(map(str, b)))
		else:
			b = []
			for i in range(0, n, 2):
				b.append(-a[i + 1])
				b.append(a[i])
			return ' '.join(list(map(str, b)))
	t = int(input())
	ans = []
	for _ in range(t):
		n = int(input())
		a = [int(x) for x in input().split()]
		ans.append(solve(n, a))
	p = 1
	for answer in ans:
		print(answer)
		p += 1
import sys, threading
import bisect
import math
import itertools
from sys import stdout
import heapq
from queue import PriorityQueue
from collections import deque
sys.setrecursionlimit(2 ** 32 // 2 - 1)
threading.stack_size(1 << 27)
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


import bisect
mod = 10 ** 9 + 7
eps = 10 ** (-9)

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

def __lcm(a, b):
	return a * b / __gcd(a, b)

def __fact(n):
	return 1 if n == 1 else n * __fact(n - 1)

def __mex(a):
	mex = 0
	a.sort()
	for x in a:
		if x <= mex:
			mex += 1
		else:
			break
	return mex

def __dist(x1, y1, x2, y2):
	return (x1 - x2) ** 2 + (y1 - y2) ** 2

def __getprimes(n):
	isprime = [True for i in range(n + 1)]
	primes = []
	for i in range(2, n + 1):
		if isprime[i]:
			for j in range(i * i, n + 1, i):
				isprime[j] = False
	for i in range(2, n + 1):
		if isprime[i]:
			primes.append(i)
	return primes

def __cntprimediv(n):
	ret = 0
	x = n
	i = 2
	while i * i <= x:
		while n % i == 0:
			n //= i
			ret += 1
		i += 1
	if n > 1:
		ret += 1
	return ret

def __primefactors(n):
	ret = []
	x = n
	i = 2
	while i * i <= x:
		while n % i == 0:
			ret.append(i)
			n //= i
		i += 1
	if n > 1:
		ret.append(n)
	return ret

def __sumdigit(n):
	ret = 0
	while n > 0:
		ret += n % 10
		n //= 10
	return ret

def solve(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0 for i in range(n)]
	k = n
	if n % 2 > 0:
		k = n - 3
	for i in range(0, k, 2):
		gcd = __gcd(abs(a[i]), abs(a[i + 1]))
		sign = 1
		if a[i] * a[i + 1] > 0:
			sign = -1
		b[i] = abs(a[i + 1]) // gcd
		b[i + 1] = sign * abs(a[i]) // gcd
	if k < n:
		if a[-3] + a[-2] != 0:
			gcd = __gcd(abs(a[-1]), abs(a[-3] + a[-2]))
			sign = 1
			if a[-1] * (a[-2] + a[-3]) > 0:
				sign = -1
			b[-3] = abs(a[-1]) // gcd
			b[-2] = abs(a[-1]) // gcd
			b[-1] = sign * abs(a[-2] + a[-3]) // gcd
		elif a[-2] + a[-1] != 0:
			gcd = __gcd(abs(a[-3]), abs(a[-1] + a[-2]))
			sign = 1
			if a[-3] * (a[-2] + a[-1]) > 0:
				sign = -1
			b[-1] = abs(a[-3]) // gcd
			b[-2] = abs(a[-3]) // gcd
			b[-3] = sign * abs(a[-2] + a[-1]) // gcd
		else:
			gcd = __gcd(abs(a[-2]), abs(a[-3] + a[-2]))
			sign = 1
			if a[-2] * (a[-2] + a[-3]) > 0:
				sign = -1
			b[-1] = abs(a[-2]) // gcd
			b[-3] = abs(a[-2]) // gcd
			b[-2] = sign * abs(a[-3] + a[-1]) // gcd
	print(*b)
t = 1
t = int(input())
for i in range(t):
	solve(i + 1)


import io, os, sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
output = sys.stdout.write

def solve(N, nums):
	res = []
	for i in range(0, N - 1, 2):
		(n1, n2) = (nums[i], nums[i + 1])
		res += [n2, -n1]
	if N % 2 == 1:
		(n1, n2, n3) = (nums[-3], nums[-2], nums[-1])
		if n2 + n3 != 0:
			res = res[:-2] + [n2 + n3, -n1, -n1]
		elif n1 + n2 != 0:
			res = res[:-2] + [-n3, -n3, n1 + n2]
		else:
			res = res[:-2] + [-n2, n1 + n3, -n2]
	return res

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		nums = list(map(int, input().split()))
		out = solve(N, nums)
		output(' '.join(map(str, out)) + '\n')
main()


import io, os
import sys
from sys import stdin
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, namedtuple
from math import gcd, ceil, floor, factorial
from itertools import combinations, permutations
input = sys.stdin.buffer.readline

def work(n, a):
	ans = [0] * n
	if n % 2 == 0:
		for i in range(0, n, 2):
			ans[i] = a[i + 1] * -1
			ans[i + 1] = a[i]
		return ans
	if a[0] + a[1] == 0:
		if a[0] + a[2] == 0:
			ans[0] = (a[1] + a[2]) * -1
			ans[1] = ans[2] = a[0]
		else:
			ans[1] = (a[0] + a[2]) * -1
			ans[0] = ans[2] = a[1]
	else:
		ans[2] = (a[0] + a[1]) * -1
		ans[0] = ans[1] = a[2]
	for i in range(3, n, 2):
		ans[i] = a[i + 1] * -1
		ans[i + 1] = a[i]
	return ans

def main():
	test = int(input())
	for idt in range(test):
		n = int(input())
		a = list(map(int, input().split()))
		ans = work(n, a)
		t = 0
		for i in range(n):
			t += ans[i] * a[i]
			print(ans[i], end=' ')
		print()
	return
main()


import sys
input = sys.stdin.readline

def get_integers():
	return map(int, input().strip().split())
t = int(input().strip())
for _ in range(t):
	n = int(input().strip())
	arr = [int(x) for x in input().strip().split()]
	if n % 2 == 0:
		for i in range(1, n, 2):
			print(arr[i], -arr[i - 1], end=' ')
	else:
		if arr[0] + arr[1] != 0:
			print(-arr[2], -arr[2], arr[0] + arr[1], end=' ')
		elif arr[1] + arr[2] != 0:
			print(arr[1] + arr[2], -arr[0], -arr[0], end=' ')
		else:
			print(-arr[1], arr[0] + arr[2], -arr[1], end=' ')
		for i in range(3, n, 2):
			print(arr[i + 1], -arr[i], end=' ')
	print()


import sys
import math
inp = sys.stdin.readline

def solve():
	n = int(inp())
	a = list(map(int, inp().split()))
	c = [None] * n
	h = 0
	for i in range(n - 2):
		if abs(h + a[i]) <= abs(h - a[i]):
			h += a[i]
			c[i] = 1
		else:
			h -= a[i]
			c[i] = -1
	i = n - 2
	if i >= 0:
		if h + a[i] != 0:
			h += a[i]
			c[i] = 1
		else:
			h -= a[i]
			c[i] = -1
	if h == 0:
		raise Exception('wut')
	if h < 0:
		h = -h
		for i in range(n - 1):
			c[i] = -c[i]
	d = a[-1]
	e = 1
	if d < 0:
		e = -1
		d = -d
	lcm = h * d // math.gcd(h, d)
	x = lcm // h
	c[-1] = -lcm // d * e
	for i in range(n - 1):
		c[i] *= x
	h = 0
	for i in range(n):
		h += c[i] * a[i]
	print(' '.join(map(str, c)))

def main():
	for i in range(int(inp())):
		solve()
main()


import math
import os
import sys
from io import BytesIO, IOBase
from types import GeneratorType
from collections import defaultdict
BUFSIZE = 8192
from bisect import bisect_left
from bisect import bisect_right

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')
t = int(input())
for _ in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		i = 0
		while i < n:
			ans.append(b[i + 1])
			ans.append(-b[i])
			i += 2
	else:
		if b[0] == b[1]:
			if b[2] == 10000:
				ans.append(1)
				ans.append(b[2] - 1)
				ans.append(-b[0])
			elif b[2] == -1:
				ans.append(1)
				ans.append(b[2] - 1)
				ans.append(-b[0])
			else:
				ans.append(-1)
				ans.append(b[2] + 1)
				ans.append(-b[0])
		if len(ans) == 0 and b[0] + b[1] == 0:
			if b[2] == 1:
				ans.append(1)
				ans.append(b[2] + 1)
				ans.append(b[0])
			elif b[2] == -1:
				ans.append(-1)
				ans.append(b[2] - 1)
				ans.append(b[0])
			elif b[2] != 10000:
				ans.append(1)
				ans.append(b[2] + 1)
				ans.append(b[0])
			else:
				ans.append(-1)
				ans.append(b[2] - 1)
				ans.append(b[0])
		if len(ans) == 0:
			poss = [-b[0] + b[1], b[0] - b[1], b[0] + b[1], -b[0] - b[1]]
			if abs(poss[0]) <= 10000:
				ans.append(-b[2])
				ans.append(b[2])
				ans.append(-poss[0])
			elif abs(poss[1]) <= 10000:
				ans.append(b[2])
				ans.append(-b[2])
				ans.append(-poss[1])
			elif abs(poss[2]) <= 10000:
				ans.append(b[2])
				ans.append(b[2])
				ans.append(-poss[2])
			elif abs(poss[3]) <= 10000:
				ans.append(-b[2])
				ans.append(-b[2])
				ans.append(-poss[3])
		i = 3
		while i < n:
			ans.append(b[i + 1])
			ans.append(-b[i])
			i += 2
	print(*ans)


from sys import stdin
read = stdin.readline
for _ in range(int(read())):
	n = int(read())
	arr = list(map(int, read().split()))
	if n % 2 == 0:
		for i in range(0, n, 2):
			print(-arr[i + 1], arr[i], end=' ')
	else:
		if -(arr[1] + arr[2]) != 0:
			print(-(arr[1] + arr[2]), arr[0], arr[0], end=' ')
		elif -(arr[0] + arr[1]) != 0:
			print(arr[2], arr[2], -(arr[0] + arr[1]), end=' ')
		elif -(arr[0] + arr[2]) != 0:
			print(arr[1], -(arr[0] + arr[2]), arr[1], end=' ')
		for i in range(3, n, 2):
			print(-arr[i + 1], arr[i], end=' ')
	print()


import math
import os
import sys
from sys import *
from decimal import *
from io import BytesIO, IOBase
import threading
from itertools import *
from collections import *
from array import *
import random
M = 10 ** 9 + 7
import heapq
import bisect
from functools import lru_cache
from queue import PriorityQueue
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] == key:
			return mid
		if arr[mid] <= key:
			left = mid + 1
		else:
			right = mid - 1
	return -1

def sumofdigits(n):
	n = str(n)
	s1 = 0
	for i in n:
		s1 += int(i)
	return s1

def perfect_square(n):
	s = math.sqrt(n)
	if s == int(s):
		return True
	return False

def luckynumber(x, n, a):
	if x > 0:
		a.append(x)
	if x > 10 ** 9:
		return a
	elif x < 1000000000000.0:
		luckynumber(x * 10 + 4, n, a)
		luckynumber(x * 10 + 7, n, a)

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

def query1(l, r):
	if l >= r:
		return -1
	print('?', l + 1, r + 1)
	sys.stdout.flush()
	return int(input()) - 1

def answer(p):
	print('!', p + 1)
	sys.stdout.flush()
	exit()

def rse(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(n)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(n)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def lse(arr, n):
	stack = []
	ans = []
	for i in range(n):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) != 0:
				if stack[-1][0] >= arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	return ans

def mah(arr):
	max1 = 0
	p = rse(arr, len(arr))
	q = lse(arr, len(arr))
	for i in range(len(arr)):
		a = (p[i] - q[i] - 1) * arr[i]
		max1 = max(a, max1)
	return max1

def maxSumIS(arr, n):
	msis = arr.copy()
	for i in range(1, n):
		for j in range(i):
			if arr[i] > arr[j] and msis[i] < msis[j] + arr[i]:
				msis[i] = msis[j] + arr[i]
	c = max(msis)
	p = 5
	return c

def binarysearch2(arr, target):
	lo = 0
	hi = len(arr) - 1
	while lo <= hi:
		mid = (lo + hi) // 2
		if arr[mid] == target:
			if mid != len(arr) - 1:
				if arr[mid + 1] != target:
					return mid
				else:
					lo += 1
			else:
				return mid
			continue
		if arr[mid] > target:
			hi = mid - 1
		else:
			lo = mid + 1

def nge(arr, n):
	stack = []
	ans = []
	for i in range(n - 1, -1, -1):
		if len(stack) == 0:
			ans.append(-1)
		else:
			while len(stack) > 0:
				if stack[-1][0] < arr[i]:
					stack.pop()
				else:
					break
			if len(stack) == 0:
				ans.append(-1)
			else:
				ans.append(stack[-1][1])
		stack.append([arr[i], i])
	ans.reverse()
	return ans

def alperm(nums, path, result):
	if not nums:
		result.add(tuple(path))
		return
	for i in range(0, len(nums)):
		alperm(nums[:i] + nums[i + 1:], path + [nums[i]], result)
	return result

def minsum(arr, n, m, res, l):
	if n == 1 and m == 1:
		res += arr[0][0]
		l.append(res)
	else:
		if n != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n - 1, m, p, l)
		if m != 1:
			p = res + arr[n - 1][m - 1]
			minsum(arr, n, m - 1, p, l)
	return min(l)

def find_shortest_path(graph, start, end, path):
	path = path + [start]
	if start == end:
		return path
	if start not in graph:
		return None
	shortest = None
	for node in graph[start]:
		if node not in path:
			newpath = find_shortest_path(graph, node, end, path)
			if newpath:
				if not shortest or len(newpath) < len(shortest):
					shortest = newpath
	return shortest

def test(n, d):
	a = random.randint(1, n - 2)
	p = pow(a, d, n)
	if p == 1 or p == n - 1:
		return True
	while d != n - 1:
		d *= 2
		p = pow(p, 2, n)
		if p == n - 1:
			return True
	return False

def isprime(n):
	if n == 1:
		return False
	if n == 2:
		return True
	if n == 3:
		return True
	d = n - 1
	while d % 2 == 0:
		d //= 2
	for i in range(5):
		if test(n, d) == False:
			return False
	return True

def muin(a, m):
	(x, y, mo) = (1, 0, m)
	if m == 1:
		return 0
	while m > 0:
		(x, y) = (y, x - a // m * y)
		(a, m) = (m, a % m)
	if x < 0:
		return mo + x
	else:
		return x

def good(l, c):
	ch = chr(c)
	if len(l) == 1:
		return 1 if ch != l[0] else 0
	k = len(l) // 2
	lm = k - l[:k].count(ch) + good(l[k:], c + 1)
	rm = k - l[k:].count(ch) + good(l[:k], c + 1)
	return min(lm, rm)

def facto(fact):
	(fact[0], fact[1]) = (1, 1)
	for i in range(2, 10 ** 6 + 1):
		fact[i] = fact[i - 1] * i % M

def comb(n, r, fact):
	return fact[n] * pow(fact[n - r] * fact[r], M - 2, M) % M

def numberToBase(n, b):
	if n == 0:
		return 0
	digits = []
	while n:
		digits.append(n % b)
		n //= b
	return sum(digits)

def main():
	t = 1
	t = int(input())
	for tc in range(1, t + 1):
		n = inpu()
		a = lis()
		b = []
		if n % 2 == 0:
			i = 0
			b = [0] * n
			while i < n:
				(b[i], b[i + 1]) = (a[i + 1], a[i] * -1)
				i += 2
			print(*b)
		else:
			b = [0] * n
			i = 0
			while i < n - 3:
				(b[i], b[i + 1]) = (a[i + 1] * -1, a[i])
				i += 2
			(a, bb, c) = (a[-3], a[-2], a[-1])
			if a + bb == 0:
				b[-3] = c * -1
				b[-2] = c
				b[-1] = a - bb
			else:
				b[-3] = c * -1
				b[-2] = c * -1
				b[-1] = a + bb
			print(*b)
main()


import sys
import math
import heapq
import bisect
from collections import Counter
from collections import defaultdict
from io import BytesIO, IOBase
from itertools import permutations
import string

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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
		self.BUFSIZE = 8192

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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 = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.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:
			self.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')

def get_int():
	return int(input())

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

def get_int_grid(n):
	return [get_ints() for _ in range(n)]

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

def get_strs():
	return get_str().split(' ')

def flat_list(arr):
	return [item for subarr in arr for item in subarr]

def yes_no(b):
	if b:
		return 'YES'
	else:
		return 'NO'

def binary_search(good, left, right, delta=1, right_true=False):
	limits = [left, right]
	while limits[1] - limits[0] > delta:
		if delta == 1:
			mid = sum(limits) // 2
		else:
			mid = sum(limits) / 2
		if good(mid):
			limits[int(right_true)] = mid
		else:
			limits[int(~right_true)] = mid
	if good(limits[int(right_true)]):
		return limits[int(right_true)]
	else:
		return False

def prefix_sums(a):
	p = [0]
	for x in a:
		p.append(p[-1] + x)
	return p

def solve_d():
	n = get_int()
	a = get_ints()
	ans = [None] * n
	C = defaultdict(list)
	for (i, x) in enumerate(a):
		C[x].append(i)
		if len(C[x]) == 2:
			(i, j) = (C[x].pop(), C[x].pop())
			ans[i] = 1
			ans[j] = -1
			(last_i, last_j) = (i, j)
	rem = []
	for (k, v) in C.items():
		while v:
			rem.append((k, v.pop()))
	if len(rem) == 1:
		(k, v) = rem.pop()
		ans[v] = 2 * a[last_i] * a[last_j]
		ans[last_i] = -a[v] * a[last_j]
		ans[last_j] = -a[v] * a[last_i]
	if len(rem) % 2 == 1:
		(k1, v1) = rem.pop()
		(k2, v2) = rem.pop()
		(k3, v3) = rem.pop()
		ans[v1] = 2 * a[v2] * a[v3]
		ans[v2] = -a[v1] * a[v3]
		ans[v3] = -a[v1] * a[v2]
	while rem:
		(k1, v1) = rem.pop()
		(k2, v2) = rem.pop()
		ans[v1] = a[v2]
		ans[v2] = -a[v1]
	return ans
t = get_int()
for _ in range(t):
	print(*solve_d())


def case():
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			ans.append(a[i + 1])
			ans.append(-a[i])
	else:
		if a[0] + a[1] != 0:
			ans = [a[2], a[2], -(a[0] + a[1])]
		elif a[0] + a[2] != 0:
			ans = [a[1], -(a[0] + a[2]), a[1]]
		else:
			ans = [-(a[1] + a[2]), a[0], a[0]]
		for i in range(3, n, 2):
			ans.append(a[i + 1])
			ans.append(-a[i])
	print(' '.join(map(str, ans)))

def main():
	T = int(input())
	for _ in range(T):
		case()
main()


import collections as cc
import bisect as bi
import itertools
import math as mt
import sys
input = sys.stdin.readline
q = lambda x: print('?', *x, flush=True)
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n,) = I()
	ar = I()
	if not n % 2:
		temp = ar.copy()[::-1]
		for i in range(n // 2):
			temp[i] *= -1
		print(*temp)
	else:
		mid = n // 2
		temp = ar.copy()[::-1]
		for i in range(n // 2 + 1):
			temp[i] *= -1
		sig = temp[mid - 1] // abs(temp[mid - 1])
		sig1 = ar[mid] // abs(ar[mid])
		if sig != sig1:
			temp[i] = ar[i - 1]
			temp[i - 1] -= ar[i]
		else:
			temp[i] = -ar[i - 1]
			temp[i - 1] += ar[i]
		print(*temp)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0 for i in range(n)]
	point = 0
	if n % 2 == 1:
		if a[0] == a[1]:
			ans[0] = abs(a[2]) + 1
			ans[1] = -1
			if a[2] == abs(a[2]):
				ans[2] = -a[0]
			else:
				ans[2] = a[0]
		else:
			ans[0] = a[2]
			ans[1] = -a[2]
			ans[2] = a[1] - a[0]
		point = 3
	while point <= n - 2:
		ans[point] = a[point + 1]
		ans[point + 1] = -a[point]
		point += 2
	print(*ans)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	res = [0] * n
	(d, dd) = (dict(), dict())
	s = set(range(n))
	chk = []
	for (i, v) in enumerate(a):
		try:
			d[v] += 1
			dd[v].append(i)
		except:
			d[v] = 1
			dd[v] = [i]
	for x in d.keys():
		if d[x] <= 1:
			continue
		if d[x] % 2:
			for y in range(0, d[x] - 1, 2):
				res[dd[x][y]] = 1
				res[dd[x][y + 1]] = -1
				s.remove(dd[x][y])
				s.remove(dd[x][y + 1])
		else:
			for y in range(0, d[x], 2):
				res[dd[x][y]] = 1
				res[dd[x][y + 1]] = -1
				s.remove(dd[x][y])
				s.remove(dd[x][y + 1])
		if len(chk) == 0:
			chk += [dd[x][0], dd[x][1]]
	if len(s) == 0:
		print(*res)
		continue
	if len(s) % 2 == 0:
		s = list(s)
		for x in range(0, len(s), 2):
			res[s[x]] = a[s[x + 1]]
			res[s[x + 1]] = -a[s[x]]
		print(*res)
		continue
	if len(s) == 1:
		s = list(s)
		(t1, t2, t3) = (s[0], chk[0], chk[1])
		res[t1] = a[t2] * a[t3]
		res[t2] = a[t1] * a[t3]
		res[t3] = -2 * a[t1] * a[t2]
		print(*res)
		continue
	if len(s) == 3:
		s = list(s)
		res[s[0]] = a[s[1]] * a[s[2]]
		res[s[1]] = a[s[0]] * a[s[2]]
		res[s[2]] = -2 * a[s[0]] * a[s[1]]
		print(*res)
		continue
	s = list(s)
	res[s[0]] = a[s[1]] * a[s[2]]
	res[s[1]] = a[s[0]] * a[s[2]]
	res[s[2]] = -2 * a[s[0]] * a[s[1]]
	for x in range(3, len(s), 2):
		res[s[x]] = a[s[x + 1]]
		res[s[x + 1]] = -a[s[x]]
	print(*res)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 10

def solve(N, A):
	A1 = [(abs(A[i]), A[i], i) for i in range(N)]
	A1.sort(reverse=True)
	result = [0] * N
	j = 0
	while j < N - 3:
		(ab1, a1, i1) = A1[j]
		(ab2, a2, i2) = A1[j + 1]
		result[i1] = a2
		result[i2] = -a1
		j += 2
	if N % 2 == 0:
		(ab1, a1, i1) = A1[j]
		(ab2, a2, i2) = A1[j + 1]
		result[i1] = a2
		result[i2] = -a1
	else:
		for (k1, k2, k3) in itertools.permutations([j, j + 1, j + 2]):
			(ab1, a1, i1) = A1[k1]
			(ab2, a2, i2) = A1[k2]
			(ab3, a3, i3) = A1[k3]
			if a2 + a3 != 0:
				result[i1] = a2 + a3
				result[i2] = -a1
				result[i3] = -a1
				break
	return result
T0 = int(input())
for _ in range(T0):
	N = int(input())
	A = list(map(int, input().split()))
	print(*solve(N, A))


t = int(input())
for z in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				print(arr[i + 1], end=' ')
			elif i == n - 1:
				print(-1 * arr[i - 1])
			else:
				print(-1 * arr[i - 1], end=' ')
	else:
		for i in range(n - 3):
			if i % 2 == 0:
				print(arr[i + 1], end=' ')
			else:
				print(-1 * arr[i - 1], end=' ')
		if arr[n - 2] + arr[n - 3] != 0:
			print(-1 * arr[n - 1], end=' ')
			print(-1 * arr[n - 1], end=' ')
			print(arr[n - 2] + arr[n - 3])
		elif arr[n - 1] + arr[n - 3] != 0:
			print(-1 * arr[n - 2], end=' ')
			print(arr[n - 1] + arr[n - 3], end=' ')
			print(-1 * arr[n - 2])
		elif arr[n - 1] + arr[n - 2] != 0:
			print(arr[n - 1] + arr[n - 2], end=' ')
			print(-1 * arr[n - 3], end=' ')
			print(-1 * arr[n - 3])


import sys

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

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

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

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

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(n, arr):
	ans = [1 for i in range(n)]
	if n % 2 == 0:
		for i in range(0, n, 2):
			ans[i] = arr[i + 1]
			ans[i + 1] = -arr[i]
		print(*ans)
		return
	for i in range(0, n - 4, 2):
		ans[i] = arr[i + 1]
		ans[i + 1] = -arr[i]
	flag = 0
	if (arr[n - 3] != arr[n - 2] and arr[n - 2] != arr[n - 1]) and arr[n - 3] != arr[n - 1]:
		ans[n - 3] = arr[n - 2] - arr[n - 1]
		ans[n - 2] = arr[n - 1] - arr[n - 3]
		ans[n - 1] = arr[n - 3] - arr[n - 2]
		print(*ans)
		return
	if arr[n - 3] + arr[n - 2] != 0:
		ans[n - 3] = -arr[n - 1]
		ans[n - 2] = -arr[n - 1]
		ans[n - 1] = arr[n - 2] + arr[n - 3]
	elif arr[n - 2] + arr[n - 1] != 0:
		ans[n - 3] = arr[n - 1] + arr[n - 2]
		ans[n - 2] = -arr[n - 3]
		ans[n - 1] = -arr[n - 3]
	else:
		ans[n - 3] = -arr[n - 2]
		ans[n - 2] = arr[n - 3] + arr[n - 1]
		ans[n - 1] = -arr[n - 2]
	print(*ans)
T = get_int()
while T:
	n = get_int()
	arr = get_list()
	solve(n, arr)
	T -= 1


from math import gcd
for i in range(int(input())):
	n = int(input())
	lst = [int(x) for x in input().split()]
	lst1 = []
	minimum = lst.index(min(lst, key=lambda x: abs(x)))
	s = 0
	for i in range(n):
		if i != minimum:
			if s > 0:
				lst1.append(-1)
				s -= lst[i]
			else:
				lst1.append(1)
				s += lst[i]
		else:
			lst1.append(1)
	if s == 0:
		if minimum != n - 1:
			lst1[-1] *= -1
			s += 2 * lst1[-1] * lst[-1]
		else:
			lst1[-2] *= -1
			s += 2 * lst1[-2] * lst[-2]
	if s < 0:
		for i in range(n):
			lst1[i] *= -1
		s *= -1
	lcm = s * lst[minimum] // gcd(s, lst[minimum])
	mult = lcm // s
	line = []
	for i in range(n):
		if i != minimum:
			line.append(str(mult * lst1[i]))
		else:
			line.append(str(-lcm // lst[minimum]))
	print(' '.join(line))


from sys import stdin

def gcd(n, m):
	while m:
		(n, m) = (m, n % m)
	return n

def read_input():
	n = int(stdin.readline().rstrip())
	a = list(map(int, stdin.readline().split()))
	return (n, a)

def solve(n, a):
	b = [0] * n
	for i in range(0, n - 1, 2):
		g = gcd(abs(a[i + 1]), abs(a[i]))
		b[i] = a[i + 1] // g
		b[i + 1] = -a[i] // g
	if n % 2 == 1:
		g = gcd(abs(a[-1]), abs(a[-2]))
		if a[-1] * b[-2] > 0:
			b[-2] += a[-1] // g
			b[-1] = -a[-2] // g
		else:
			b[-2] -= a[-1] // g
			b[-1] = a[-2] // g
	return ' '.join(map(str, b))

def main():
	t = int(stdin.readline())
	for _ in range(t):
		input = read_input()
		answer = solve(*input)
		print(answer)
main()


def bsdk(ans, i, j, k):
	ans.append(-(i + j), k, k)
t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	if n % 2 == 0:
		ans = []
		for i in range(n // 2):
			ans.append(-arr[2 * i + 1])
			ans.append(arr[2 * i])
		print(*ans)
	else:
		ans = []
		if arr[1] + arr[0] != 0:
			ans.append(arr[2])
			ans.append(arr[2])
			ans.append(-(arr[0] + arr[1]))
		elif arr[1] + arr[2] != 0:
			ans.append(-(arr[1] + arr[2]))
			ans.append(arr[0])
			ans.append(arr[0])
		else:
			ans.append(arr[1])
			ans.append(-(arr[2] + arr[0]))
			ans.append(arr[1])
		arr.pop(0)
		arr.pop(0)
		arr.pop(0)
		n = n - 3
		for i in range(n // 2):
			ans.append(-arr[2 * i + 1])
			ans.append(arr[2 * i])
		print(*ans)


import sys
from math import factorial, gcd
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify, nlargest, nsmallest
from itertools import groupby, accumulate
from copy import deepcopy
MOD = 10 ** 9 + 7
INF = float('inf')
input = sys.stdin.readline
rl = lambda : list(map(int, input().split()))
rs = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	A = rl()
	res = [0] * n
	s = 0
	if n % 2 == 1:
		if A[0] != A[1]:
			res[0] = -A[2]
			res[1] = A[2]
			res[2] = A[0] - A[1]
		else:
			res[0] = res[1] = A[2]
			res[2] = -2 * A[0]
		s = 3
	for i in range(s, n, 2):
		res[i] = A[i + 1]
		res[i + 1] = -A[i]
	print(*res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(b, i) = ([0 for _ in range(n)], 0)
	if n % 2 == 1:
		if a[0] == -a[1]:
			b[0:3] = [2 * a[2], a[2], -a[0]]
		else:
			b[0:3] = [a[2], a[2], -a[0] - a[1]]
		i = 3
	(altre, skipped) = ({}, set())
	for j in range(i, n):
		if abs(a[j]) in altre:
			other = altre[abs(a[j])]
			altre.pop(abs(a[j]))
			if a[j] == a[other]:
				(b[j], b[other]) = (1, -1)
			else:
				(b[j], b[other]) = (1, 1)
			skipped.add(j)
			skipped.add(other)
		else:
			altre[abs(a[j])] = j
	while i < n:
		if i in skipped:
			i += 1
		else:
			nou_i = i + 1
			while nou_i in skipped:
				nou_i += 1
			b[i] = a[nou_i]
			b[nou_i] = -a[i]
			i = nou_i + 1
	assert 0 not in b
	print(' '.join((str(v) for v in b)))


DEBUG = 0
if DEBUG == 1:
	data = open('1.in', 'r')

def readline():
	if DEBUG == 1:
		return data.readline().strip('\r\n')
	else:
		try:
			return input().strip('\r\n')
		except EOFError:
			return ''

def readi():
	return [int(t) for t in readline().split()]
(tc,) = readi()
for _ in range(tc):
	(n,) = readi()
	a = readi()
	if n % 2 == 0:
		for i in range(0, n - 1, 2):
			print(a[i + 1], -a[i], end=' ')
		print()
	else:
		for i in range(0, n - 4, 2):
			print(a[i + 1], -a[i], end=' ')
		a1 = a[-3]
		a2 = a[-2]
		a3 = a[-1]
		(b1, b2, b3) = (0, 0, 0)
		if a2 + a3 != 0:
			b1 = -(a2 + a3)
			b2 = a1
			b3 = a1
		elif a1 + a3 != 0:
			b1 = a2
			b2 = -(a1 + a3)
			b3 = a2
		elif a1 + a2 != 0:
			b1 = a3
			b2 = a3
			b3 = -(a1 + a2)
		print(b1, b2, b3)
if DEBUG == 1:
	data.close()


t = int(input())
mp = [1, -1]
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 0:
		print(' '.join((str(a[i + j] * mp[j]) for i in range(0, n, 2) for j in (1, 0))))
		continue
	y = sorted(map(abs, a))
	for i in range(n - 1):
		if y[i] == y[i + 1]:
			break
	else:
		print(' '.join((str(a[i + j] * mp[j]) for i in range(0, n - 3, 2) for j in (1, 0))), a[-1] * a[-2], a[-1] * a[-3], -2 * a[-2] * a[-3])
		continue
	v = y[i]
	(p1, p2, p3) = (-1, -1, -1)
	for j in range(n):
		if abs(a[j]) == v:
			if p1 == -1:
				p1 = j
			elif p2 == -1:
				p2 = j
			else:
				break
	if 1000000000 - sum(y) < 10000:
		for i in range(n - 2):
			if y[i] == y[i + 1] == y[i + 2]:
				break
		v = y[i]
		(p1, p2, p3) = (-1, -1, -1)
		for j in range(n):
			if abs(a[j]) == v:
				if p1 == -1:
					p1 = j
				elif p2 == -1:
					p2 = j
				elif p3 == -1:
					p3 = j
				else:
					break
		vs = [0] * n
		op = -1
		for i in range(n):
			if i == p1 or i == p2 or i == p3:
				continue
			if op == -1:
				op = i
			else:
				vs[op] = a[i]
				vs[i] = -a[op]
				op = -1
		(vs[p1], vs[p2], vs[p3]) = (1, 1, -2)
		if a[p1] < 0:
			vs[p1] = -vs[p1]
		if a[p2] < 0:
			vs[p2] = -vs[p2]
		if a[p3] < 0:
			vs[p3] = -vs[p3]
		print(' '.join((str(e) for e in vs)))
	else:
		vs = [0] * n
		op = -1
		for i in range(n):
			if i == p1 or i == p2:
				continue
			if op == -1:
				op = i
			else:
				vs[op] = a[i]
				vs[i] = -a[op]
				op = -1
		vs[p1] = a[op]
		vs[p2] = a[op]
		vs[op] = -2 * a[p1]
		if (a[p1] < 0) != (a[p2] < 0):
			vs[p2] = -vs[p2]
		print(' '.join((str(e) for e in vs)))


t = int(input())
for _ in range(t):
	n = int(input())
	mass = list(map(int, input().split()))
	mass1 = [1 for _ in range(n)]
	if len(mass) % 2 == 0:
		for i in range(1, len(mass), 2):
			mass1[i - 1] = -mass[i]
			mass1[i] = mass[i - 1]
	else:
		for i in range(1, len(mass) - 3, 2):
			mass1[i - 1] = -mass[i]
			mass1[i] = mass[i - 1]
		strrr = mass[n - 3:]
		plus = []
		minus = []
		for i in range(len(strrr)):
			if strrr[i] > 0:
				plus.append(i + n - 3)
			else:
				minus.append(i + n - 3)
		if len(minus) == 0:
			minus.append(plus[0])
			del plus[0]
		elif len(plus) == 0:
			plus.append(minus[0])
			del minus[0]
		if len(plus) > len(minus):
			mass1[plus[0]] = -mass[minus[0]]
			mass1[plus[1]] = -mass[minus[0]]
			mass1[minus[0]] = mass[plus[0]] + mass[plus[1]]
		else:
			mass1[minus[0]] = -mass[plus[0]]
			mass1[minus[1]] = -mass[plus[0]]
			mass1[plus[0]] = mass[minus[0]] + mass[minus[1]]
	print(*mass1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		ans = list(reversed(arr))
		for i in range(n // 2):
			ans[i] = -ans[i]
	else:
		ans = list(reversed(arr))
		for i in range(n // 2):
			ans[i] = -ans[i]
		if arr[n // 2] == -arr[-1]:
			ans[n // 2] = ans[-1]
			ans[-1] *= 2
		else:
			ans[n // 2] = arr[0]
			ans[0] += -arr[n // 2]
	print(' '.join(map(str, ans)))


for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	b = []
	if n % 2:
		for i in range(0, n - 3, 2):
			b += [-s[i + 1], s[i]]
		if s[-2] + s[-3] != 0:
			b += [-s[-1]]
			b += [-s[-1]]
			b += [s[-2] + s[-3]]
		elif s[-1] + s[-3] != 0:
			b += [-s[-2]]
			b += [s[-1] + s[-3]]
			b += [-s[-2]]
		else:
			b += [s[-1] + s[-2]]
			b += [-s[-3]]
			b += [-s[-3]]
	else:
		for i in range(0, n, 2):
			b += [-s[i + 1], s[i]]
	print(*b)


from math import *

def sign(num):
	return -1 if num < 0 else 1
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n % 2:
		(a, b, c, *l) = l
		print(abs(b) * sign(a), (abs(a) + abs(c)) * -sign(b), abs(b) * sign(c), end=' ')
	for i in range(0, len(l), 2):
		print(abs(l[i + 1]) * -sign(l[i]), abs(l[i]) * sign(l[i + 1]), end=' ')
	print()


import math

def GCD(a, b, c):
	if a < 0:
		a = -a
	if b < 0:
		b = -b
	if c < 0:
		c = -c
	d = math.gcd(a, b)
	d = math.gcd(d, c)
	return d

def GCDT(a, b):
	if a < 0:
		a = -a
	if b < 0:
		b = -b
	d = math.gcd(a, b)
	return d
n = int(input())
for i in range(n):
	len = int(input())
	lineX = input().split()
	line = []
	for s in lineX:
		line.append(int(s))
	i = 0
	if len % 2 == 1:
		a = line[1] + line[2]
		b = -line[0]
		c = -line[0]
		if a == 0:
			a = line[1] - line[2]
			c = -c
		d = GCD(a, b, c)
		print(str(int(a / d)), str(int(b / d)), str(int(c / d)), end='')
		i = 3
	while i < len:
		if i != 0:
			print(' ', end='')
		a = line[i]
		b = line[i + 1]
		d = GCDT(a, b)
		a = int(a / d)
		b = int(b / d)
		print(str(b), str(-a), end='')
		i += 2
	print()


from sys import stdin
input = stdin.readline
rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input().strip()
YN = lambda x: print('YES') if x else print('NO')
mod = 10 ** 9 + 7
for _ in range(rn()):
	n = rn()
	a = rl()
	ans = []

	def solve(b):
		ans = []
		for i in range(0, len(b), 2):
			ans.append(-b[i + 1])
			ans.append(b[i])
		return ans
	if n % 2 == 0:
		ans = solve(a)
	else:
		(x, b, c) = a[:3]
		l = len({x, b, c})
		if l == 3:
			pre = [b - c, c - x, x - b]
		elif l == 1:
			pre = [1, 1, -2]
		elif x == b:
			pre = [x, c - x, -x]
		elif x == c:
			pre = [x, -x, b - x]
		else:
			pre = [-b, b, x - b]
		ans = pre + solve(a[3:])
	print(*ans)


import sys
input = sys.stdin.readline

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

def find_b(arr):
	min_abs = 10 ** 4 + 1
	idx = -1
	for i in range(len(arr)):
		if abs(arr[i]) < abs(min_abs):
			min_abs = arr[i]
			idx = i
	b = [0 for _ in range(len(arr))]
	v = 0
	for i in range(len(arr)):
		if i == idx:
			continue
		g = gcd(min_abs, arr[i])
		t1 = -arr[i] // g
		t2 = min_abs // g
		if v >= 0:
			if t1 < 0:
				v += t1
				b[i] = t2
			else:
				v -= t1
				b[i] = -t2
		elif t1 < 0:
			v -= t1
			b[i] = -t2
		else:
			v += t1
			b[i] = t2
	if v == 0:
		min_used = 10 ** 4 + 1
		min_idx = 0
		for i in range(len(arr)):
			if i == idx:
				continue
			if abs(b[i]) < abs(min_used):
				min_used = b[i]
				min_idx = i
		g = gcd(min_abs, arr[min_idx])
		t1 = -arr[min_idx] // g
		t2 = min_abs // g
		if min_used * t2 < 0:
			v -= t1
			b[min_idx] -= t2
		else:
			v += t1
			b[min_idx] += t2
	b[idx] = v
	for i in range(len(arr)):
		print(b[i], end=' ')
	print()
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	find_b(arr)


import sys
import math
import random
import collections

def solve(a, b, c):
	if c == 0:
		return (0, 0)
	if a > b:
		(x, y) = solve(b, a, c)
		return (y, x)
	if c % a == 0:
		return (c // a, 0)
	if c % b == 0:
		return (0, c // b)
	if c >= a:
		(x, y) = solve(a, b, c % a)
		return (x + c // a, y)
	(x, y) = solve(b % a, a, c)
	return (y - b // a * x, x)
T = int(sys.stdin.readline().strip())
for _ in range(T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split(' ')))
	cnt = collections.Counter(a)
	if len(cnt) == 1:
		res = [1] * n
		res[0] = -n + 1
		print(' '.join(map(str, res)))
		continue
	if len(cnt) == 2:
		(x, y) = list(cnt.keys())
		if x == -y:
			res = [1] * n
			res[0] = -(sum(a) // a[0]) + 1
			while res[0] == 0 or res[1] == 0:
				if a[0] == a[1]:
					res[0] += 1
					res[1] -= 1
				else:
					res[0] += 1
					res[1] += 1
			print(' '.join(map(str, res)))
			continue
	if n == 2:
		(x, y) = a
		g = math.gcd(x, y)
		print(y // g, -x // g)
		continue
	keys = list(cnt.keys())
	p = random.choice(keys)
	q = random.choice(keys)
	while abs(p) == abs(q):
		q = random.choice(keys)
	for i in range(n):
		if a[i] == p:
			p = i
			break
	for i in range(n):
		if a[i] == q:
			q = i
			break
	s = 0
	res = [0] * n
	g = math.gcd(abs(a[p]), abs(a[q]))
	for i in range(n):
		if i == p or i == q:
			continue
		if a[i] <= 0 and s <= 0:
			res[i] = -g
			s -= a[i] * g
		elif a[i] <= 0 <= s:
			res[i] = g
			s += a[i] * g
		elif s <= 0 <= a[i]:
			res[i] = g
			s += a[i] * g
		elif a[i] >= 0 and s >= 0:
			res[i] = -g
			s -= a[i] * g
	target = -s
	aa = abs(a[p])
	bb = abs(a[q])
	gap = math.gcd(aa, bb)
	aa //= gap
	bb //= gap
	cc = abs(target) // gap
	(x, y) = solve(aa, bb, cc)
	while x == 0 or y == 0:
		x += bb
		y += -aa
	flag = 0
	for i in {-1, 1}:
		for j in {-1, 1}:
			if a[p] * x * i + a[q] * y * j == target:
				res[p] = x * i
				res[q] = y * j
				flag = 1
				break
		if flag:
			break
	print(' '.join(map(str, res)))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = [int(c) for c in input().split()]
	m = n if n % 2 == 0 else n - 1
	ar = [0 for i in range(n)]
	for i in range(0, m, 2):
		ar[i] = arr[i + 1] * -1
		ar[i + 1] = arr[i]
	if n % 2 == 1:
		ar[-2] += arr[-1]
		if ar[-2] == 0:
			ar[-2] += arr[-1]
			ar[-1] = arr[-2] * -2
		else:
			ar[-1] = arr[-2] * -1
	print(*ar)


from math import *
from random import *
import sys
input = sys.stdin.readline

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

def st():
	return input().rstrip('\n')

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

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	if n % 2 == 0:
		b = [-1] * n
		for i in range(n // 2):
			b[i] = -a[n - i - 1]
			b[n - i - 1] = a[i]
		print(*b)
	else:
		x = a[-1]
		y = a[-2]
		z = a[-3]
		req = x * z + y * z
		fl = 0
		if req == 0:
			fl = 1
			req = x * z + y * -z
		req = req // z
		req = -req
		n -= 3
		b = [-1] * n
		for i in range(n // 2):
			b[i] = -a[n - i - 1]
			b[n - i - 1] = a[i]
		b.append(req)
		if fl:
			b.append(-z)
		else:
			b.append(z)
		b.append(z)
		print(*b)


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	n = I()
	a = L()
	if n % 2 == 0:
		for i in range(0, n, 2):
			(a[i], a[i + 1]) = (-a[i + 1], a[i])
		print(*a)
	else:
		for i in range(0, n - 3, 2):
			(a[i], a[i + 1]) = (-a[i + 1], a[i])
		s = a[-1] + a[-2] + a[-3]
		for i in range(n - 3, n):
			if s - a[i] != 0:
				for j in range(n - 3, n):
					if j != i:
						a[j] = a[i]
				a[i] -= s
				break
		print(*a)


def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	sum = 0
	mini = min(a, key=abs)
	idx = a.index(mini)
	for i in range(n):
		if i == idx:
			b.append(0)
			continue
		if a[i] == sum:
			sum = sum + a[i]
			b.append(1)
		elif a[i] == -1 * sum:
			sum = sum - a[i]
			b.append(-1)
		elif sum > 0 and a[i] < 0:
			sum = sum + a[i]
			b.append(1)
		elif sum > 0 and a[i] > 0:
			sum = sum - a[i]
			b.append(-1)
		elif sum < 0 and a[i] > 0:
			sum = sum + a[i]
			b.append(1)
		elif sum < 0 and a[i] < 0:
			sum = sum - a[i]
			b.append(-1)
		elif sum == 0:
			sum = sum + a[i]
			b.append(1)
	sum = sum * -1
	rem = sum % mini
	if rem == 0:
		b[idx] = sum // mini
		print(*b)
	else:
		val = mini // gcd(rem, mini)
		b = [val * b[i] for i in range(n)]
		sum = sum * val
		b[idx] = sum // mini
		print(*b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			b += [-a[i + 1]]
			b += [a[i]]
	else:
		(x, y, z) = (a[0], a[1], a[2])
		if y + z != 0:
			b += [-(y + z), x, x]
		elif x + y != 0:
			b += [z, z, -(x + y)]
		else:
			b += [y, -(x + z), y]
		for i in range(3, n, 2):
			b += [-a[i + 1]]
			b += [a[i]]
	print(' '.join(map(str, b)))


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []

def update_it(bit, i, val):
	n = len(bit)
	while i < n:
		bit[i] += val
		i += i & -i

def get_ans(bit, i):
	n = len(bit)
	tot = 0
	while i > 0:
		tot += bit[i]
		i -= i & -i
	return tot

def hnbhai(tc):
	n = sb()
	a = sd()
	b = [0] * n
	for i in range(1, n, 2):
		b[i] = -a[i - 1]
		b[i - 1] = a[i]
	if n % 2 == 0:
		print(*b)
		return
	if n <= 3:
		x = sum(a)
		ind = 0
		b = [1] * n
		for i in range(n):
			if x - a[i] != 0:
				if abs(a[i]) * (n - 1) + abs(x - a[i]) <= 10 ** 9:
					ind = a[i]
					b = [ind] * n
					b[i] = -(x - a[i])
					break
		print(*b)
		return
	x = a[-1] + a[-2] + a[-3]
	ind = 0
	for i in range(n - 3, n):
		if x - a[i] != 0:
			if abs(a[i]) * 2 + abs(x - a[i]) <= 10 ** 9:
				ind = a[i]
				b[-1] = b[-2] = b[-3] = ind
				b[i] = -(x - a[i])
				break
	print(*b)
for _ in range(sb()):
	hnbhai(_ + 1)


import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split()))
	ans = []
	if n % 2 == 0:
		m = n // 2
	else:
		m = (n - 3) // 2
	for i in range(0, m):
		b1 = a[2 * i + 1]
		b2 = -a[2 * i]
		if b1 % b2 == 0:
			(b1, b2) = (b1 // b2, 1)
		if b2 % b1 == 0:
			(b2, b1) = (b2 // b1, 1)
		ans.append(b1)
		ans.append(b2)
	if n % 2 == 1:
		if a[n - 1] + a[n - 2] != 0:
			ans.append(a[n - 2] + a[n - 1])
			ans.append(-a[n - 3])
			ans.append(-a[n - 3])
		else:
			ans.append(a[n - 2] - a[n - 1])
			ans.append(-a[n - 3])
			ans.append(a[n - 3])
	print(' '.join(list(map(str, ans))))


from sys import stdin, stdout
from random import randint
print = stdout.write
input = stdin.readline

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

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

def solve_test():
	n = int(input())
	a = [int(x) for x in input().split()]
	A = a.copy()
	ans = []
	final = []
	if n % 2 == 1:
		T = 1
		if a[-2] // abs(a[-2]) != a[-3] // abs(a[-3]):
			a[-3] = -a[-3]
			T = -1
		d = lcm(a[-1], a[-2] + a[-3])
		k = d // (a[-2] + a[-3])
		final.append(-k * T)
		final.append(-k)
		final.append(d // a[-1])
		a.pop()
		a.pop()
		a.pop()
		n -= 3
	for i in range(n // 2):
		d = lcm(a[i * 2], a[i * 2 + 1])
		ans.append(-d // a[i * 2])
		ans.append(d // a[i * 2 + 1])
	ans += final
	return ' '.join((str(s) for s in ans))

def main(args=None):
	tests = int(input())
	for _ in range(tests):
		print(f'{solve_test()}\n')
main()


import sys
input = sys.stdin.buffer.readline

def check(a, b):
	res = 0
	for i in range(n):
		res += a[i] * b[i]
	return res

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	if n % 2 == 0:
		for i in range(n // 2):
			(l, r) = (i * 2, i * 2 + 1)
			b[l] = a[r]
			b[r] = -a[l]
	else:
		array = sorted([(abs(val), val, i) for (i, val) in enumerate(a)], reverse=True)
		stack = []
		for (_, val, i) in array[:-2]:
			if not stack:
				stack.append((val, i))
				continue
			(v, j) = stack[-1]
			if abs(val) == abs(v):
				if val == v:
					b[i] = -1
					b[j] = 1
				else:
					b[i] = 1
					b[j] = 1
				stack.pop()
			else:
				stack.append((val, i))
		for (_, val, i) in array[-2:]:
			stack.append((val, i))
		(vi, i) = stack.pop()
		(vj, j) = stack.pop()
		(vk, k) = stack.pop()
		b[i] = vj + vk
		b[j] = -vi + vk
		b[k] = -vi - vj
		while stack:
			(vl, l) = stack.pop()
			(vr, r) = stack.pop()
			b[l] = vr
			b[r] = -vl
	idx = -1
	for i in range(n):
		if b[i] == 0:
			idx = i
	if idx == -1:
		print(*b)
		continue
	nxt_idx = (idx + 1) % n
	val1 = a[nxt_idx] // gcd(a[idx], a[nxt_idx])
	val2 = -a[idx] // gcd(a[idx], a[nxt_idx])
	if b[nxt_idx] + val2 != 0:
		b[idx] += val1
		b[nxt_idx] += val2
	else:
		b[idx] -= val1
		b[nxt_idx] -= val2
	print(*b)


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

def lcm(a, b):
	return abs(a * b) // gcd(a, b)
t = int(input())
for test_case in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	if n % 2:
		sum_of_first_two = a[0] + a[1]
		num_multiplier = 1
		if not sum_of_first_two:
			num_multiplier = 2
			sum_of_first_two = a[0] + a[1] * num_multiplier
		lowest_common_multiple = lcm(sum_of_first_two, a[2])
		b.append(f'{lowest_common_multiple / sum_of_first_two:.0f}')
		b.append(f'{lowest_common_multiple / sum_of_first_two * num_multiplier:.0f}')
		b.append(f'{lowest_common_multiple / a[2] * -1:.0f}')
		for i in range(3, n, 2):
			lowest_common_multiple = lcm(a[i], a[i + 1])
			b.append(f'{lowest_common_multiple / a[i]:.0f}')
			b.append(f'{lowest_common_multiple / a[i + 1] * -1:.0f}')
	else:
		for i in range(0, n, 2):
			lowest_common_multiple = lcm(a[i], a[i + 1])
			b.append(f'{lowest_common_multiple / a[i]:.0f}')
			b.append(f'{lowest_common_multiple / a[i + 1] * -1:.0f}')
	print(' '.join(b))


t = int(input())
for _ in range(t):
	vup = 8
	n = int(input())
	a = list(map(int, input().split()))
	vup = 1
	b = [0 for i in range(n)]
	if n % 2 == 0:
		vup = 5
		for i in range(n):
			vup = 4
			b[i] = a[i // 2 * 2 + (1 - i % 2)] * (-1) ** (i % 2)
	else:
		vup = 7
		for i in range(n - 3):
			vup = 3
			b[i] = a[i // 2 * 2 + (1 - i % 2)] * (-1) ** (i % 2)
		if a[-3] == a[-2] and a[-2] == a[-1]:
			vup = 6
			b[-3] = 1
			b[-2] = 1
			vup = 2
			b[-1] = -2
		elif a[-3] == a[-2]:
			b[-3] = a[-2] - a[-1]
			vup = 8
			b[-2] = -a[-3]
			vup = 23
			b[-1] = a[-3]
		elif a[-2] == a[-1]:
			b[-3] = a[-2]
			vup = 2
			vup = 34
			b[-2] = a[-1] - a[-3]
			b[-1] = -a[-2]
		elif a[-3] == a[-1]:
			vup = 26
			b[-3] = a[-1] - a[-2]
			vup = 32
			b[-2] = a[-3]
			b[-1] = -a[-3]
		else:
			vup = 73
			b[-3] = a[-2] - a[-1]
			b[-2] = a[-1] - a[-3]
			vup = 29
			b[-1] = a[-3] - a[-2]
	print(' '.join(map(str, b)))


from math import gcd, log
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	g = abs(a[0])
	for v in a:
		g = gcd(abs(v), g)
	out = [0] * n
	out[0] += a[1]
	out[1] -= a[0]
	seen = dict()
	seen[a[0]] = 0
	seen[a[1]] = 1
	for i in range(2, n):
		if a[i] in seen:
			while out[i] == 0 or out[seen[a[i]]] == 0:
				out[i] += 1
				out[seen[a[i]]] -= 1
		else:
			while out[i] == 0 or out[i - 1] == 0:
				out[i] += a[i - 1]
				out[i - 1] -= a[i]
		seen[a[i]] = i
	print(' '.join(map(str, out)))


from sys import stdin, stdout, setrecursionlimit
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
from heapq import heapify, heappush, heappop, heappushpop
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = L()
	b = []
	for i in range(0, n - 3 * (n % 2), 2):
		(x, y) = (a[i], a[i + 1])
		g = lcm(abs(x), abs(y))
		if x // abs(x) == y // abs(y):
			x = abs(x)
			y = abs(y)
			b += (g // x,)
			b += (-g // y,)
		else:
			x = abs(x)
			y = abs(y)
			b += (g // x,)
			b += (g // y,)
	if n % 2:
		(x, y, z) = (a[-3], a[-2], a[-1])
		g = lcm(abs(x) + abs(y), abs(z))
		b += (abs(x) // x * (g // (abs(x) + abs(y))),)
		b += (abs(y) // y * (g // (abs(x) + abs(y))),)
		b += (g // abs(z) * (-1 if abs(z) == z else 1),)
	print(*b)


from __future__ import division, print_function
import math
import sys
import os
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')

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))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

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

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

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

def gcd_extend(a, b):
	global x, y
	if b == 0:
		x = 1
		y = 0
		return a
	else:
		g = gcd_extend(b, a % b)
		(x1, y1) = (x, y)
		x = y1
		y = x1 - math.floor(a / b) * y1
		return g

def gcdeu(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def solution(a, b, c):
	gcd = gcd_extend(a, b)
	return (int(x * (c / gcd)), int(y * (c / gcd)))
for _ in range(inp()):
	n = inp()
	l = inlt()
	if n % 2 == 0:
		b = []
		for i in range(0, n, 2):
			b.append(-l[i + 1])
			b.append(l[i])
	else:
		(a1, a2, a3) = (l[0], l[1], l[2])
		if a1 + a2 != 0:
			b = [a3, a3, -a1 - a2]
		elif a2 + a3 != 0:
			b = [-a2 - a3, a1, a1]
		else:
			b = [a2, -a1 - a3, a2]
		for i in range(3, n, 2):
			b.append(-l[i + 1])
			b.append(l[i])
	print(*b)


def answer():
	N = int(input())
	a = list(map(int, input().split()))
	m = min((abs(i) for i in a))
	b = [1] * N
	tS = 0
	flg = -1
	for i in range(N):
		if abs(a[i]) == m and flg == -1:
			flg = i
			continue
		if tS * a[i] < 0 and tS + a[i] != 0:
			b[i] = 1
			tS += a[i]
		elif tS - a[i] != 0:
			b[i] = -1
			tS -= a[i]
		else:
			b[i] = 1
			tS += a[i]
	from math import gcd
	m_coeff = tS * m // gcd(tS, m) // m
	s_coeff = tS * m // gcd(tS, m) // tS
	for i in range(N):
		if i != flg:
			b[i] *= s_coeff
		else:
			b[i] = m_coeff
	if sum((a[i] * b[i] for i in range(N))) != 0:
		b[flg] -= 2 * m_coeff
	print(*b)
	return
t = int(input())
for _ in range(t):
	answer()


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	L = len(arr)
	ans = [0] * L
	if L % 2 != 0:
		v1 = arr[0] + arr[1]
		v2 = arr[2]
		if v1 == 0:
			v1 = arr[0] - arr[1]
			(ans[0], ans[1]) = (v2, -v2)
			ans[2] = -v1
		else:
			(ans[0], ans[1]) = (v2, v2)
			ans[2] = -v1
	for i in range(0 if L % 2 == 0 else 3, L, 2):
		(ans[i], ans[i + 1]) = (arr[i + 1], -arr[i])
	print(*ans)
for _ in range(t):
	solve()


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	brr = [0] * n
	n_ = n if n % 2 == 0 else n - 1
	for i in range(n_ // 2):
		brr[i] = -arr[n_ - 1 - i]
		brr[n_ - 1 - i] = arr[i]
	if n % 2 == 1:
		(t1, t2) = (arr[n - 1], -arr[n - 2])
		if t1 + brr[n - 2] == 0:
			(t1, t2) = (-t1, -t2)
		brr[n - 2] += t1
		brr[n - 1] += t2
	for b in brr:
		print(b, end=' ')
	print()
	t -= 1


inf = float('inf')
import sys
import pprint
import logging
from logging import getLogger
import array

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

def maps():
	return [int(i) for i in input().split()]
logging.basicConfig(format='%(message)s', level=logging.WARNING)
logger = getLogger(__name__)
logger.setLevel(logging.INFO)

def debug(msg, *args):
	logger.info(f'{msg}={pprint.pformat(args)}')
(tc,) = maps()
while tc:
	tc -= 1
	(n,) = maps()
	(a, b) = ([*maps()], array.array('q'))
	start = 0
	if n % 2:
		if a[0] + a[1] != 0:
			b.append(-a[2])
			b.append(-a[2])
			b.append(a[1] + a[0])
		elif a[1] + a[2] != 0:
			b.append(a[1] + a[2])
			b.append(-a[0])
			b.append(-a[0])
		else:
			b.append(-a[1])
			b.append(a[0] + a[2])
			b.append(-a[1])
		start = 3
	while start < n:
		b.append(a[start + 1])
		b.append(-a[start])
		start += 2
	print(*b)


for j in range(int(input())):
	n = int(input())
	mas = list(map(int, input().split()))
	out = []
	if n % 2 == 0:
		for i in range(len(mas) // 2):
			out.append(mas[i * 2 + 1])
			out.append(-mas[i * 2])
	else:
		for i in range(len(mas) // 2 - 1):
			out.append(mas[i * 2 + 1])
			out.append(-mas[i * 2])
		ost = mas[-3:]
		if ost[0] + ost[1] != 0:
			out.append(-ost[2])
			out.append(-ost[2])
			out.append(ost[0] + ost[1])
		elif ost[1] + ost[2] != 0:
			out.append(ost[1] + ost[2])
			out.append(-ost[0])
			out.append(-ost[0])
		else:
			out.append(-ost[1])
			out.append(ost[0] + ost[2])
			out.append(-ost[1])
	print(*out)


import os
import sys
import math
from io import BytesIO, IOBase
import io
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
from collections import Counter
import threading
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')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10001)]
prime[0] = prime[1] = False

def SieveOfEratosthenes(n=10000):
	p = 2
	c = 0
	while p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				prime[i] = False
		p += 1

class DSU:

	def __init__(self, R, C):
		self.par = range(R * C + 1)
		self.rnk = [0] * (R * C + 1)
		self.sz = [1] * (R * C + 1)

	def find(self, x):
		if self.par[x] != x:
			self.par[x] = self.find(self.par[x])
		return self.par[x]

	def union(self, x, y):
		(xr, yr) = (self.find(x), self.find(y))
		if xr == yr:
			return
		if self.rnk[xr] < self.rnk[yr]:
			(xr, yr) = (yr, xr)
		if self.rnk[xr] == self.rnk[yr]:
			self.rnk[xr] += 1
		self.par[yr] = xr
		self.sz[xr] += self.sz[yr]

	def size(self, x):
		return self.sz[self.find(x)]

	def top(self):
		return self.size(len(self.sz) - 1) - 1

class LazySegTree:

	def __init__(self, _op, _e, _mapping, _composition, _id, v):

		def set(p, x):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			_d[p] = x
			for i in range(1, _log + 1):
				_update(p >> i)

		def get(p):
			assert 0 <= p < _n
			p += _size
			for i in range(_log, 0, -1):
				_push(p >> i)
			return _d[p]

		def prod(l, r):
			assert 0 <= l <= r <= _n
			if l == r:
				return _e
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r >> i)
			sml = _e
			smr = _e
			while l < r:
				if l & 1:
					sml = _op(sml, _d[l])
					l += 1
				if r & 1:
					r -= 1
					smr = _op(_d[r], smr)
				l >>= 1
				r >>= 1
			return _op(sml, smr)

		def apply(l, r, f):
			assert 0 <= l <= r <= _n
			if l == r:
				return
			l += _size
			r += _size
			for i in range(_log, 0, -1):
				if l >> i << i != l:
					_push(l >> i)
				if r >> i << i != r:
					_push(r - 1 >> i)
			l2 = l
			r2 = r
			while l < r:
				if l & 1:
					_all_apply(l, f)
					l += 1
				if r & 1:
					r -= 1
					_all_apply(r, f)
				l >>= 1
				r >>= 1
			l = l2
			r = r2
			for i in range(1, _log + 1):
				if l >> i << i != l:
					_update(l >> i)
				if r >> i << i != r:
					_update(r - 1 >> i)

		def _update(k):
			_d[k] = _op(_d[2 * k], _d[2 * k + 1])

		def _all_apply(k, f):
			_d[k] = _mapping(f, _d[k])
			if k < _size:
				_lz[k] = _composition(f, _lz[k])

		def _push(k):
			_all_apply(2 * k, _lz[k])
			_all_apply(2 * k + 1, _lz[k])
			_lz[k] = _id
		_n = len(v)
		_log = _n.bit_length()
		_size = 1 << _log
		_d = [_e] * (2 * _size)
		_lz = [_id] * _size
		for i in range(_n):
			_d[_size + i] = v[i]
		for i in range(_size - 1, 0, -1):
			_update(i)
		self.set = set
		self.get = get
		self.prod = prod
		self.apply = apply
MIL = 1 << 20

def makeNode(total, count):
	return total * MIL + count

def getTotal(node):
	return math.floor(node / MIL)

def getCount(node):
	return node - getTotal(node) * MIL
nodeIdentity = makeNode(0.0, 0.0)

def nodeOp(node1, node2):
	return node1 + node2
	return makeNode(getTotal(node1) + getTotal(node2), getCount(node1) + getCount(node2))
identityMapping = -1

def mapping(tag, node):
	if tag == identityMapping:
		return node
	count = getCount(node)
	return makeNode(tag * count, count)

def composition(mapping1, mapping2):
	return mapping1 if mapping1 != identityMapping else mapping2

class LazySegUpdate:

	def __init__(self, N):
		self.N = N
		n = 4 * N
		self.tree = [0] * n
		self.lazy = [0] * n

	def queryHelper(self, index, s, e, l, r):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return 0
		if s >= l and e <= r:
			return self.tree[index]
		mid = (s + e) // 2
		return max(self.queryHelper(2 * index, s, mid, l, r), self.queryHelper(2 * index + 1, mid + 1, e, l, r))

	def updateHelper(self, index, s, e, l, r, h):
		if self.lazy[index]:
			update = self.lazy[index]
			self.lazy[index] = 0
			self.tree[index] = max(self.tree[index], update)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], update)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], update)
		if s > e or s > r or e < l:
			return
		if s >= l and e <= r:
			self.tree[index] = max(self.tree[index], h)
			if s != e:
				self.lazy[2 * index] = max(self.lazy[2 * index], h)
				self.lazy[2 * index + 1] = max(self.lazy[2 * index + 1], h)
			return
		mid = (s + e) // 2
		self.updateHelper(2 * index, s, mid, l, r, h)
		self.updateHelper(2 * index + 1, mid + 1, e, l, r, h)
		self.tree[index] = max(self.tree[2 * index], self.tree[2 * index + 1])

	def query(self, l, r):
		return self.queryHelper(1, 0, self.N - 1, l, r - 1)

	def update(self, l, r, h):
		self.updateHelper(1, 0, self.N - 1, l, r - 1, h)

def memodict(f):

	class memodict(dict):

		def __missing__(self, key):
			ret = self[key] = f(key)
			return ret
	return memodict().__getitem__

def pollard_rho(n):
	if n & 1 == 0:
		return 2
	if n % 3 == 0:
		return 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			prev = p
			p = p * p % n
			if p == 1:
				return math.gcd(prev - 1, n)
			if p == n - 1:
				break
		else:
			for i in range(2, n):
				(x, y) = (i, (i * i + 1) % n)
				f = math.gcd(abs(x - y), n)
				while f == 1:
					(x, y) = ((x * x + 1) % n, (y * y + 1) % n)
					y = (y * y + 1) % n
					f = math.gcd(abs(x - y), n)
				if f != n:
					return f
	return n

@memodict
def prime_factors(n):
	if n <= 1:
		return Counter()
	f = pollard_rho(n)
	return Counter([n]) if f == n else prime_factors(f) + prime_factors(n // f)

def distinct_factors(n):
	factors = [1]
	for (p, exp) in prime_factors(n).items():
		factors += [p ** i * factor for factor in factors for i in range(1, exp + 1)]
	return factors

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	if small[-1] == large[-1]:
		large.pop()
	large.reverse()
	small.extend(large)
	return small

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = n
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = mid
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = -1
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = mid
			left = mid + 1
	return res
t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [0] * n
	for i in range(0, n - 1, 2):
		b[i] = a[i + 1]
		b[i + 1] = -a[i]
	if n % 2:
		for i in range(n - 1):
			if b[i] + a[-1] != 0:
				b[i] += a[-1]
				b[-1] = -a[i]
				break
			elif b[i] - a[-1] != 0:
				b[i] -= a[-1]
				b[-1] = a[i]
				break
	print(*b)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().strip().split()]
	results = []
	if n % 2:
		if a[1] + a[2] != 0:
			results.append(a[1] + a[2])
			results.append(-a[0])
			results.append(-a[0])
		elif a[0] + a[2] != 0:
			results.append(-a[1])
			results.append(a[0] + a[2])
			results.append(-a[1])
		elif a[0] + a[1] != 0:
			results.append(-a[2])
			results.append(-a[2])
			results.append(a[1] + a[0])
	else:
		results.append(a[1])
		results.append(-a[0])
	for i in range(2 + n % 2, n, 2):
		results.append(a[i + 1])
		results.append(-a[i])
	print(' '.join((str(i) for i in results)))


from sys import *
input = stdin.readline
import threading
from bisect import *
import math
from collections import *
import operator
from heapq import *
from itertools import *
inf = 10 ** 19
mod = 10 ** 9 + 7
MOD = 998244353
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
dx = [-1, 0]
dy = [0, -1]
setrecursionlimit(200005)

def asc(c):
	return ord(c) - 97 + 1

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

def lcm(a, b):
	a = abs(a)
	b = abs(b)
	return a * b // gcd(a, b)
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	temp = [0] * n
	if n % 2 == 0:
		for i in range(0, n, 2):
			gg = lcm(a[i], a[i + 1])
			temp[i] = -gg // a[i]
			temp[i + 1] = gg // a[i + 1]
	else:
		for i in range(0, n - 3, 2):
			gg = lcm(a[i], a[i + 1])
			temp[i] = -gg // a[i]
			temp[i + 1] = gg // a[i + 1]
		gg = lcm(a[-1], a[-2])
		gg = lcm(gg, a[-3])
		temp[-3] = -gg // a[-3]
		temp[-2] = -gg // a[-2]
		temp[-1] = gg * 2 // a[-1]
	print(*temp)


T = int(input())
for test in range(1, T + 1):
	N = int(input())
	nums = [int(S) for S in input().split()]
	ans = [0 for S in range(N)]
	st = 0
	if N % 2 != 0:
		(i, j, k) = (0, 1, 2)
		if nums[i] + nums[j] == 0:
			if nums[j] != nums[k]:
				(j, k) = (k, j)
			else:
				(i, k) = (k, i)
		(ans[i], ans[j], ans[k]) = (str(-nums[k]), str(-nums[k]), str(nums[i] + nums[j]))
		st = 3
	for i in range(st, N, 2):
		(ans[i], ans[i + 1]) = (str(nums[i + 1]), str(-nums[i]))
	print(' '.join(ans))


import collections
import os
import sys
from datetime import date
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')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)
import math
import statistics
from bisect import bisect_right
for __ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	if n % 2 == 0:
		for i in range(0, n, 2):
			ans.append(a[i + 1])
			ans.append(-a[i])
	else:
		for i in range(0, n - 3, 2):
			ans.append(a[i + 1])
			ans.append(-a[i])
		if a[-1] + a[-2] != 0:
			ans.append(a[-1] + a[-2])
			ans.append(-a[-3])
			ans.append(-a[-3])
		elif a[-2] + a[-3] != 0:
			ans.append(-a[-1])
			ans.append(-a[-1])
			ans.append(a[-2] + a[-3])
		else:
			ans.append(-a[-2])
			ans.append(a[-1] + a[-3])
			ans.append(-a[-2])
	print(*ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	p = -1
	for i in range(len(a)):
		if i % 2 != 0:
			a[i] = -a[i]
	b = list()
	for i in range(len(a)):
		if i % 2 == 0:
			b.append(1)
		else:
			b.append(-1)
	for i in range(len(a)):
		if sum(a) - a[i] != 0:
			p = i
			break
	sm = sum(a) - a[p]
	total = 0
	k = 0
	l = 99999
	while l:
		l -= 1
		k += 1
		total = sm * k
		if k * (n - 1) + abs(int(-total / a[p])) < 1000000000:
			if total % a[p] == 0:
				break
	for j in range(n):
		if j == p:
			print(int(-total / a[p]) * b[j], end=' ')
		else:
			print(k * b[j], end=' ')
	print()


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

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

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

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

def isprime(n):
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def solve():
	for _ in range(1, ii() + 1):
		n = ii()
		a = li()
		res = [0] * n
		for i in range(n // 2):
			(l, r) = (a[i], a[n - i - 1])
			p = l * r // gcd(l, r)
			res[i] = p // l
			res[n - i - 1] = -p // r
		if n & 1:
			r1 = n // 2
			tot = sum(res)
			ok = False
			for i in range(n):
				if i == r1:
					continue
				(l, r) = (a[i], a[r1])
				p = l * r // gcd(l, r)
				x1 = p // l
				x2 = -(p // r)
				if res[i] + x1:
					res[i] += x1
					res[r1] += x2
					ok = True
					break
			if ok == False:
				res = [0] * n
				(l1, r1) = (0, n - 2)
				for i in range(n // 2):
					(l, r) = (a[l1], a[r1])
					p = l * r // gcd(l, r)
					res[l1] = p // l
					res[r1] = -p // r
					r1 -= 1
					l1 += 1
				r1 = n - 1
				tot = sum(res)
				for i in range(n):
					if i == r1:
						continue
					(l, r) = (a[i], a[r1])
					p = l * r // gcd(l, r)
					x1 = p // l
					x2 = -(p // r)
					if res[i] + x1:
						res[i] += x1
						res[r1] += x2
						ok = True
						break
		print(*res)
		s = 0
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()