There are $N$ cities on a circle, numbered $1$ through $N$. For each $i$ ($1 \le i \le N-1$), cities $i$ and $i+1$ are directly connected by a bidirectional road with length $A_i$, and cities $N$ and $1$ are also directly connected by a bidirectional road with length $A_N$. However, we do not know the lengths of some roads.
For each city $i$, we do know that it has an opposite city — formally, there is a city $j \neq i$ such that the clockwise distance between cities $i$ and $j$ is equal to the counterclockwise distance between these cities.
Please find the lengths of all roads in such a way that the above condition is satisfied and the sum of lengths of all roads is minimised.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of the input contains a single integer $N$.
- The second line contains $N$ space-separated integers $A_1, A_2, \dots, A_N$. For each valid $i$, $A_i = -1$ denotes that the length of road $i$ is unknown.

-----Output-----
For each test case, print a line containing the string "NO" if there is no solution or "YES" otherwise. If a solution exists, print a second line containing $N$ space-separated positive integers — the lengths of all roads in your solution. Each of these integers should be $\le 10^9$. If there are multiple solutions, you may print any one.

-----Constraints-----
- $1 \le T \le 100$
- $3 \le N \le 10^5$
- $1 \le A_i \le 10^9$ or $A_i = -1$ for each valid $i$
- the sum of $N$ for all test cases does not exceed $3\cdot 10^5$

-----Subtasks-----
Subtask #1 (10 points): $N \le 4$
Subtask #2 (20 points): $A_i = \pm 1$ for each valid $i$
Subtask #3 (70 points): original constraints

-----Example Input-----
4
4
1 1 1 1
4
1 1 1 2
4
1 -1 -1 4
4
1 -1 2 -1

-----Example Output-----
YES
1 1 1 1
NO
YES
1 4 1 4
NO

Difficulty: MEDIUM_HARD

Solutions:
def m(l, n):
	if n % 2 != 0:
		print('NO')
	else:
		c = 0
		for i in range(n // 2):
			if l[i] == l[n // 2 + i]:
				if l[i] == -1:
					l[i] = 1
					l[n // 2 + i] = 1
					continue
				else:
					continue
			elif l[i] == -1:
				l[i] = l[n // 2 + i]
				continue
			elif l[n // 2 + i] == -1:
				l[n // 2 + i] = l[i]
				continue
			else:
				print('NO')
				c += 1
				break
		if c == 0:
			print('YES')
			print(*l)
t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	m(l, n)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	dist = list(map(int, input().split()))
	if n % 2 != 0:
		print('NO')
	else:
		f = 1
		for i in range(n // 2):
			if dist[i] != dist[i + n // 2] and dist[i] != -1 and (dist[i + n // 2] != -1):
				f = 0
				break
			elif dist[i] == -1 and dist[i + n // 2] == -1:
				dist[i] = 1
				dist[i + n // 2] = 1
			else:
				dist[i] = dist[i + n // 2] = max(dist[i], dist[i + n // 2])
		if f == 0:
			print('NO')
		else:
			print('YES')
			print(' '.join(map(str, dist)))


for _ in range(int(input())):
	N = int(input())
	array = list(map(int, input().split()))
	if N % 2 != 0:
		print('NO')
	else:
		possible = True
		p = N // 2
		for i in range(p):
			if array[i] == -1:
				if array[p + i] == -1:
					array[i] = 1
					array[p + i] = 1
				else:
					array[i] = array[p + i]
			elif array[p + i] == -1:
				array[p + i] = array[i]
			elif array[i] != array[p + i]:
				possible = False
				break
		if possible:
			print('YES')
			print(*array)
		else:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
		continue
	fl = 0
	for i in range(n // 2):
		if a[i] == -1 and a[i + n // 2] == -1:
			a[i] = 1
			a[n // 2 + i] = 1
		elif a[i] == -1:
			a[i] = a[n // 2 + i]
		elif a[n // 2 + i] == -1:
			a[n // 2 + i] = a[i]
		elif a[i] != a[i + n // 2]:
			fl = 1
			break
	if fl:
		print('NO')
		continue
	else:
		print('YES')
		print(*a)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split()))
	if n % 2 == 0:
		yes = False
		for j in range(n):
			if a[j] != 1 and a[j] != -1:
				yes = True
				break
		if not yes:
			print('YES')
			print('1 ' * (n - 1), end='')
			print('1')
		else:
			impossible = False
			for j in range(n // 2):
				if a[j] == a[j + n // 2]:
					if a[j] == -1:
						a[j] = 1
						a[j + n // 2] = 1
				elif a[j] == -1:
					a[j] = a[j + n // 2]
				elif a[j + n // 2] == -1:
					a[j + n // 2] = a[j]
				else:
					impossible = True
					break
			if impossible:
				print('NO')
			else:
				print('YES')
				for i in range(n - 1):
					print(a[i], end=' ')
				print(a[n - 1])
	else:
		print('NO')


t = int(input())
for i in range(t):
	N = int(input())
	l = list(map(int, input().split()))
	if N % 2 == 0:
		f = 0
		for j in range(N // 2):
			if l[j] == -1 and l[N // 2 + j] == -1:
				l[j] = 1
				l[N // 2 + j] = 1
			elif l[j] == -1:
				l[j] = l[N // 2 + j]
			elif l[N // 2 + j] == -1:
				l[N // 2 + j] = l[j]
			elif l[j] == l[N // 2 + j]:
				pass
			else:
				print('NO')
				f += 1
				break
		if f == 0:
			print('YES')
			print(*l)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	lens = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
		continue
	hn = n // 2
	ans = 'YES'
	for ix in range(hn):
		if lens[ix] == -1:
			if lens[ix + hn] == -1:
				lens[ix + hn] = 1
			lens[ix] = lens[ix + hn]
		elif lens[ix + hn] == -1:
			lens[ix + hn] = lens[ix]
		elif lens[ix + hn] != lens[ix]:
			ans = 'NO'
			break
	print(ans)
	if ans == 'YES':
		print(*lens)


for _ in range(int(input())):
	(n, ans) = (int(input()), 'YES')
	a = list(map(int, input().split()))
	if n & 1:
		ans = 'NO'
	else:
		for i in range(n >> 1):
			opp = i + (n >> 1)
			if a[i] != -1 and a[opp] != -1 and (a[i] != a[opp]):
				ans = 'NO'
				break
			elif a[i] == -1 and a[opp] != -1:
				a[i] = a[opp]
			elif a[i] != -1 and a[opp] == -1:
				a[opp] = a[i]
			elif a[i] == -1 and a[opp] == -1:
				a[i] = 1
				a[opp] = 1
	print(ans)
	if ans == 'YES':
		print(*a)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	if n % 2:
		print('NO')
	else:
		n //= 2
		a = list(map(int, a.split()))
		for i in range(n):
			j = i + n
			if a[i] < 0:
				if a[j] < 0:
					a[j] = 1
				a[i] = a[j]
			elif a[j] < 0:
				a[j] = a[i]
			elif a[i] != a[j]:
				print('NO')
				break
		else:
			print('YES')
			print(*a)


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	x = N // 2
	c = 0
	if N % 2 != 0:
		print('NO')
	else:
		for i in range(x):
			if A[i] == -1 and A[i + x] == -1:
				A[i] = 1
				A[i + x] = 1
			elif A[i] == -1:
				A[i] = A[i + x]
			elif A[i + x] == -1:
				A[i + x] = A[i]
		for i in range(x):
			if A[i] != A[i + x]:
				c = 1
				break
		if c == 1:
			print('NO')
		else:
			print('YES')
			print(*A)


for _ in range(int(input())):
	N = int(input())
	s = list(map(int, input().split()))
	if N % 2 != 0:
		print('NO')
		continue
	elif s[0:N // 2:1] == s[N // 2:N:1] and min(s) != -1:
		print('YES')
		print(*s, sep=' ')
		continue
	elif min(s) == -1:
		x = s
		nteql = 0
		for i in range(N // 2):
			if s[i] == -1 and s[N // 2 + i] == -1:
				(s[i], s[N // 2 + i]) = (1, 1)
			elif s[i] != -1 and s[N // 2 + i] == -1:
				s[N // 2 + i] = s[i]
			elif s[i] == -1 and s[N // 2 + i] != -1:
				s[i] = s[N // 2 + i]
		if s[0:N // 2:1] == s[N // 2:N:1]:
			print('YES')
			print(*s, sep=' ')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
for t in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	flag = 0
	if N % 2 == 1:
		print('NO')
	else:
		e = N // 2
		for i in range(e):
			if A[i] == -1 and A[(i + e) % N] == -1:
				A[i] = 1
				A[(i + e) % N] = 1
			elif A[i] == -1:
				A[i] = A[(i + e) % N]
			elif A[(i + e) % N] == -1:
				A[(i + e) % N] = A[i]
			elif A[i] != A[(i + e) % N]:
				flag = 1
				break
		if flag == 1:
			print('NO')
		else:
			print('YES')
			print(' '.join(list(map(str, A))))


import sys
try:
	sys.stdin = open('inp', 'r')
except:
	pass

def chk(a):
	n = len(a)
	if n & 1:
		return False
	for i in range(n // 2):
		if a[i] == -1 or a[i + n // 2] == -1:
			(a[i], a[i + n // 2]) = (max(a[i], a[i + n // 2]), max(a[i], a[i + n // 2]))
	for i in range(n):
		if a[i] == -1:
			a[i] = 1
	for i in range(n // 2):
		if a[i] != a[i + n // 2]:
			return False
	return True
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if chk(a):
		print('YES')
		print(*a)
	else:
		print('NO')


for i in range(int(input())):
	a = int(input())
	v = list(map(int, input().split()))
	if a % 2 == 1:
		print('NO')
		x = v[a // 2 + 1:]
	else:
		x = v[a // 2:]
		r = a // 2
		flag = 0
		for j in range(len(x)):
			if x[j] == v[j] == -1:
				v[j + r] = 1
				v[j] = 1
				continue
			elif v[j] == -1:
				v[j] = x[j]
				continue
			elif x[j] == -1:
				v[j + r] = v[j]
				continue
			elif x[j] != v[j]:
				flag = 1
				break
		if flag == 1:
			print('NO')
		else:
			print('YES')
			print(*v)


from math import ceil, sqrt
t = int(input())
for test in range(1, t + 1):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 != 0:
		print('NO')
		continue
	found = 0
	for i in range(n // 2):
		if a[i] != -1:
			if a[i + n // 2] != a[i]:
				if a[i + n // 2] != -1:
					print('NO')
					found = 1
					break
				else:
					a[i + n // 2] = a[i]
		elif a[i + n // 2] == -1:
			a[i] = 1
			a[i + n // 2] = 1
		else:
			a[i] = a[i + n // 2]
	if found != 1:
		if sum(a[:n // 2]) == sum(a) / 2:
			print('YES')
			print(*a)
		else:
			print('NO')


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 0:
		answer = 'YES'
		for i in range(n // 2):
			if a[i] == a[n // 2 + i]:
				if a[i] == -1:
					a[i] = a[n // 2 + i] = 1
			elif a[i] == -1:
				a[i] = a[n // 2 + i]
			elif a[n // 2 + i] == -1:
				a[n // 2 + i] = a[i]
			else:
				answer = 'NO'
				break
		print(answer)
		if answer == 'YES':
			print(' '.join(map(str, a)))
	else:
		print('NO')


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = 0
	for i in range(math.ceil(n // 2)):
		if n % 2 == 1:
			f = 1
			break
		elif l[i] != l[i + n // 2]:
			if min(l[i], l[i + n // 2]) == -1:
				l[i] = max(l[i], l[i + n // 2])
				l[i + n // 2] = max(l[i], l[i + n // 2])
			else:
				f = 1
				break
		elif l[i] == -1:
			l[i] = 1
			l[i + n // 2] = 1
	if f == 1:
		print('NO')
	else:
		print('YES')
		print(*l)


for ii in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	if n % 2 != 0:
		print('NO')
	else:
		correct = True
		l = int(n / 2)
		for i in range(l):
			if arr[i] > 0 and arr[i + l] > 0 and (arr[i] != arr[i + l]):
				correct = False
				break
			if arr[i] == -1 and arr[i + l] == -1:
				arr[i] = 1
				arr[i + l] = 1
				continue
			if arr[i] > 0:
				arr[i + l] = arr[i]
				continue
			if arr[i + l] > 0:
				arr[i] = arr[i + l]
		if not correct:
			print('NO')
		else:
			print('YES')
			ans = ''
			for i in range(n - 1):
				ans += str(arr[i]) + ' '
			ans += str(arr[n - 1])
			print(ans)


for t in range(int(input())):
	N = int(input())
	A = [int(i) for i in input().split()]
	n = N // 2
	f = 0
	if N % 2 == 0:
		for i in range(n):
			if A[i] != A[i + n]:
				if A[i] == -1:
					A[i] = A[i + n]
				elif A[i + n] == -1:
					A[i + n] = A[i]
				else:
					print('NO')
					f = 1
					break
			elif A[i] == -1:
				A[i] = A[i + n] = 1
		if f != 1:
			print('YES')
			print(*A, sep=' ')
	else:
		print('NO')


for _ in range(int(input())):
	N = int(input())
	A = [int(x) for x in input().split()]
	if N % 2 == 1:
		print('NO')
		continue
	else:
		x = N // 2
		for i in range(x):
			if A[i] == -1 and A[i + x] == -1:
				A[i] = 1
				A[i + x] = 1
			elif A[i] == -1:
				A[i] = A[i + x]
			elif A[i + x] == -1:
				A[i + x] = A[i]
			elif A[i] == A[i + x]:
				pass
			elif A[i] != A[i + x]:
				print('NO')
				break
		else:
			print('YES')
			print(' '.join((str(x) for x in A)))


try:
	for i in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		if n & 1:
			print('NO')
			continue
		b = n // 2
		c = 0
		for j in range(b):
			if l[j] > -1 and l[j + b] > -1 and (l[j] != l[j + b]):
				c = 1
				break
			elif l[j] == l[j + b] and l[j] == -1:
				l[j] = 1
				l[j + b] = 1
			elif l[j] == -1:
				l[j] = l[j + b]
			elif l[j + b] == -1:
				l[j + b] = l[j]
		if c == 1:
			print('NO')
		else:
			print('YES')
			for j in range(n - 1):
				print(l[j], end=' ')
			print(l[n - 1])
except:
	pass


t = int(input())
for i in range(0, t):
	n = int(input())
	a = [int(i) for i in input().split()]
	if n % 2 != 0:
		print('NO')
	else:
		i = 0
		j = n // 2
		flag = 0
		while i < n // 2:
			if a[i] == -1 and a[j] != -1:
				a[i] = a[j]
			elif a[j] == -1 and a[i] != -1:
				a[j] = a[i]
			elif a[i] == -1 and a[j] == -1:
				a[i] = 1
				a[j] = 1
			elif a[i] != a[j]:
				flag = 1
				break
			i += 1
			j += 1
		if flag == 1:
			print('NO')
		else:
			print('YES')
			print(*a, sep=' ')


for i in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n % 2 == 1:
		print('NO')
		continue
	count = 0
	for j in range(int(n / 2)):
		if a[j] == a[j + int(n / 2)] or (a[j] == -1 and a[j + int(n / 2)] != -1) or (a[j] != -1 and a[j + int(n / 2)] == -1):
			count += 1
	if count != int(n / 2):
		print('NO')
	else:
		for k in range(int(n / 2)):
			if a[k] == -1 and a[k + int(n / 2)] != -1:
				a[k] = a[k + int(n / 2)]
			elif a[k] != -1 and a[k + int(n / 2)] == -1:
				a[k + int(n / 2)] = a[k]
			elif a[k] == -1 and a[k + int(n / 2)] == -1:
				a[k] = 1
				a[k + int(n / 2)] = 1
		print('YES')
		print(*a)


T = int(input())
n = 0
for i in range(T):
	c = 0
	n = int(input())
	A = list(map(int, input().strip().split(' ')))
	if n % 2 == 1:
		print('NO')
		continue
	for j in range(int(n / 2)):
		if A[j] == -1 and A[int(j + n / 2)] != -1:
			A[j] = A[int(j + n / 2)]
		elif A[j] != -1 and A[int(j + n / 2)] == -1:
			A[int(j + n / 2)] = A[j]
		elif A[j] == -1 and A[int(j + n / 2)] == -1:
			A[j] = 1
			A[int(j + n / 2)] = 1
			continue
	for j in range(int(n / 2)):
		if A[j] != A[int(j + n / 2)]:
			c = 1
			break
	if c == 1:
		print('NO')
	else:
		print('YES')
		print(' '.join(map(str, A)))


def fun(a, n, m):
	if n % 2 == 1:
		print('NO')
		return
	for i in range(m):
		if a[i] == -1 and a[i + m] == -1:
			a[i] = 1
			a[i + m] = 1
		elif a[i] == -1 and a[i + m] != -1:
			a[i] = a[i + m]
		elif a[i] != -1 and a[i + m] == -1:
			a[i + m] = a[i]
		elif a[i] != a[i + m]:
			print('NO')
			return
	print('YES')
	print(*a)
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = n // 2
	fun(a, n, m)


t = int(input())
res = []
for _ in range(t):
	n = int(input())
	x = input().split()
	if n % 2 == 1:
		res.append('NO')
	else:
		for i in range(n // 2):
			if x[i] != x[n // 2 + i]:
				if x[i] == '-1':
					if x[n // 2 + i] == '-1':
						x[i] = '1'
						x[n // 2 + i] = '1'
					else:
						x[i] = x[n // 2 + i]
				elif x[n // 2 + i] == '-1':
					x[n // 2 + i] = x[i]
				else:
					res.append('NO')
					break
			elif x[i] == '-1':
				x[i] = '1'
				x[n // 2 + i] = '1'
		else:
			res.append('YES')
			res.append(' '.join(x))
for i in res:
	print(i)


for t in range(int(input().strip())):
	n = int(input().strip())
	a = list(map(int, input().strip().split()))
	x = n // 2
	if n % 2 == 0:
		b = True
		for i in range(x):
			if a[i] == -1 and a[i + x] == -1:
				a[i] = 1
				a[i + x] = 1
			elif a[i] == -1 and a[i + x] > 0:
				a[i] = a[i + x]
			elif a[i] > 0 and a[i + x] == -1:
				a[i + x] = a[i]
			elif a[i] != a[i + x] and a[i] > 0:
				b = False
		if b:
			print('YES')
			print(*a)
		else:
			print('NO')
	else:
		print('NO')


import sys
import math
from queue import Queue
import heapq

def main(arr):
	n = len(arr)
	if n & 1:
		print('NO')
		return
	for i in range(len(arr)):
		opposite = (i + n // 2) % n
		if arr[opposite] == -1 and arr[i] == -1:
			arr[opposite] = arr[i] = 1
		elif arr[opposite] == -1:
			arr[opposite] = arr[i]
		elif arr[i] == -1:
			arr[i] = arr[opposite]
		if arr[i] != arr[opposite]:
			print('NO')
			return
	print('YES')
	print(*arr)
	return
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	main(arr)


t = int(input())
for _ in range(t):
	n = int(input())
	L = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
		continue
	found = True
	for i in range(n // 2):
		if L[i] == -1 and L[i + n // 2] == -1:
			L[i] = L[i + n // 2] = 1
		else:
			a = L[i]
			b = L[i + n // 2]
			if a == -1:
				L[i] = b
			elif b == -1:
				L[i + n // 2] = a
			elif a == b:
				pass
			else:
				found = False
				break
	if found:
		print('YES')
		print(*L)
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
	else:
		mid = n // 2
		flag = False
		for i in range(n):
			pos = (i + mid) % n
			if a[i] == -1 and a[pos] == -1:
				a[i] = 1
				a[pos] = 1
			elif a[i] == -1 and a[pos] != -1:
				a[i] = a[pos]
			elif a[i] != -1 and a[pos] == -1:
				a[pos] = a[i]
			elif a[i] != a[pos]:
				flag = True
				break
		if flag:
			print('NO')
		else:
			print('YES')
			print(*a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 0:
		mid = n / 2
		mid = int(mid)
		suraj = 1
		for i in range(mid):
			if a[i] == -1 and a[mid + i] == -1:
				(a[i], a[mid + i]) = (1, 1)
			if a[i] != a[mid + i]:
				if a[i] == -1:
					a[i] = a[mid + i]
				elif a[mid + i] == -1:
					a[mid + i] = a[i]
				else:
					suraj = 0
					break
		if suraj == 0:
			print('NO')
		else:
			print('YES')
			for i in range(n - 1):
				print(a[i], end=' ')
			print(a[n - 1])
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
	else:
		yes = True
		for i in range(n // 2):
			if min(arr[i], arr[i + n // 2]) > 0:
				if arr[i] != arr[i + n // 2]:
					yes = False
					break
			elif max(arr[i], arr[i + n // 2]) == -1:
				arr[i] = arr[i + n // 2] = 1
			else:
				a = max(arr[i], arr[i + n // 2])
				arr[i] = arr[i + n // 2] = a
		if yes:
			print('YES')
			print(*arr)
		else:
			print('NO')
	t -= 1


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split(' ')))
	if n % 2 == 1:
		print('NO')
		continue
	p = n // 2
	z = 1
	for i in range(n // 2):
		if l[i] == -1 and l[p + i] == -1:
			l[i] = l[p + i] = 1
		elif l[i] == -1 and l[p + i] != -1:
			l[i] = l[p + i]
		elif l[i] != -1 and l[p + i] == -1:
			l[p + i] = l[i]
		elif l[i] != l[p + i]:
			z = 0
			break
	if z == 0:
		print('NO')
	else:
		print('YES')
		print(' '.join([str(i) for i in l]))


T = int(input())
for _ in range(T):
	N = int(input())
	a = list(map(int, input().split()))
	n = len(a)
	if n % 2 == 1:
		print('NO')
		continue
	f = 0
	n = N // 2
	for i in range(0, n):
		if a[i] == -1 and a[i + n] == -1:
			a[i] = 1
			a[i + n] = 1
		elif a[i] == -1:
			a[i] = a[i + n]
		elif a[i + n] == -1:
			a[i + n] = a[i]
		elif a[i] == a[i + n]:
			continue
		else:
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')
		print(' '.join(list(map(str, a))))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
		continue
	f = 0
	for i in range(math.ceil(n // 2)):
		if arr[i] != arr[i + n // 2]:
			if arr[i] == -1 or arr[i + n // 2] == -1:
				arr[i] = max(arr[i], arr[i + n // 2])
				arr[i + n // 2] = max(arr[i], arr[i + n // 2])
			else:
				f = 1
				break
		elif arr[i] == -1:
			arr[i] = 1
			arr[i + n // 2] = 1
	if f == 1:
		print('NO')
	else:
		print('YES')
		print(*arr)


T = int(input())
while T:
	N = int(input())
	road_lengths = list(map(int, input().split()))
	if N % 2 == 1:
		print('NO')
	else:
		half_N = int(N / 2)
		is_possible = True
		for i in range(half_N):
			if road_lengths[i] != -1 and road_lengths[i + half_N] != -1:
				if road_lengths[i] != road_lengths[i + half_N]:
					is_possible = False
					break
			elif road_lengths[i] == -1 and road_lengths[i + half_N] != -1:
				road_lengths[i] = road_lengths[i + half_N]
			elif road_lengths[i] != -1 and road_lengths[i + half_N] == -1:
				road_lengths[i + half_N] = road_lengths[i]
			else:
				road_lengths[i] = 1
				road_lengths[i + half_N] = 1
		if is_possible == False:
			print('NO')
		else:
			print('YES')
			print(' '.join([str(length) for length in road_lengths]))
	T -= 1


t = int(input())
for x in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	g = 0
	if n % 2 == 1:
		print('NO')
		continue
	count = 0
	for i in range(n):
		y = (i + n // 2) % n
		if arr[y] == -1 and arr[i] == -1:
			arr[y] = 1
			arr[i] = 1
			count += 1
		elif arr[i] == -1:
			arr[i] = arr[y]
			count += 1
		elif arr[y] == -1:
			arr[y] = arr[i]
			count += 1
		elif arr[i] == arr[y]:
			count += 1
	if count == n:
		print('YES')
		print(' '.join((str(e) for e in arr)))
	else:
		print('NO')


def solve(A):
	n = len(A)
	if n % 2 != 0:
		return None
	for i in range(n // 2):
		(a, b) = (A[i], A[i + n // 2])
		if a > 0 and b > 0 and (a != b):
			return None
		if a < 0 and b < 0:
			a = 1
		elif a < 0:
			a = b
		(A[i], A[i + n // 2]) = (a, a)
	return A
import sys
f = sys.stdin
t = int(f.readline())
for i in range(t):
	f.readline()
	A = list(map(int, f.readline().split()))
	x = solve(A)
	if x is None:
		print('NO')
		continue
	print('YES')
	print(' '.join(map(str, x)))


tc = int(input())
for x in range(tc):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n % 2 != 0:
		print('NO')
	else:
		a1 = a[:n // 2]
		a2 = a[n // 2:]
		t = 0
		for i in range(n // 2):
			if a1[i] != -1 and a2[i] != -1 and (a1[i] != a2[i]):
				print('NO')
				t = 1
				break
			else:
				if a1[i] == -1 and a2[i] != -1:
					a1[i] = a2[i]
				if a2[i] == -1 and a1[i] != -1:
					a2[i] = a1[i]
				if a1[i] == -1 and a2[i] == -1:
					a1[i] = a2[i] = 1
		if t == 0:
			print('YES')
			print(*a1 + a2)