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

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Mathematics

Ad-hoc


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


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 _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
		continue
	flag = False
	x = n // 2
	for i in range(n // 2):
		if a[i] == -1:
			if a[i + x] == -1:
				a[i] = 1
				a[i + x] = 1
			else:
				a[i] = a[i + x]
		elif a[i + x] == -1:
			a[i + x] = a[i]
		elif a[i] != a[i + x]:
			flag = True
			print('NO')
			break
	if not flag:
		print('YES')
		for i in a:
			print(i, end=' ')
		print()


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())
	arr = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
	else:
		flag = 1
		for i in range(n // 2):
			if arr[i] != -1 and arr[(i + n // 2) % n] != -1:
				if arr[i] != arr[(i + n // 2) % n]:
					flag = 0
					break
			elif arr[i] != -1 and arr[(i + n // 2) % n] == -1:
				arr[(i + n // 2) % n] = arr[i]
			elif arr[i] == -1 and arr[(i + n // 2) % n] != -1:
				arr[i] = arr[(i + n // 2) % n]
			else:
				arr[i] = 1
				arr[(i + n // 2) % n] = 1
		if flag == 1:
			print('YES')
			for i in arr:
				print(i, end=' ')
			print('')
		else:
			print('NO')


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	if n & 1:
		print('NO')
	else:
		j = n // 2
		c = True
		for i in range(0, n // 2):
			if arr[i] == -1 and arr[j] == -1:
				arr[i] = 1
				arr[j] = 1
			elif arr[i] == -1 or arr[j] == -1:
				if arr[i] == -1:
					arr[i] = arr[j]
				else:
					arr[j] = arr[i]
			elif arr[i] != arr[j]:
				print('NO')
				c = False
				break
			j = j + 1
		if c:
			print('YES')
			for i in arr:
				print(i, end=' ')
			print()
	t = t - 1


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 = [int(x) for x in input().split()]
	if n % 2 != 0:
		print('NO')
		continue
	x = n // 2
	possible = True
	for i in range(x):
		if a[i] == -1:
			if a[i + x] == -1:
				a[i] = 1
				a[i + x] = 1
			else:
				a[i] = a[i + x]
		elif a[i + x] == -1:
			a[i + x] = a[i]
		elif a[i] != a[i + x]:
			possible = False
			print('NO')
			break
	if possible:
		print('YES')
		for x in a:
			print(x, end=' ')
		print()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = 0
	a = [int(i) for i in input().split()]
	if n % 2 != 0:
		print('NO')
	else:
		k = n // 2
		f = 0
		for i in range(0, k):
			if a[i] != -1 and a[k + i] != -1:
				if a[i] != a[k + i]:
					f = 1
					break
				else:
					f = 0
		if f == 1:
			print('NO')
		else:
			for i in range(k):
				if a[i] == -1 and a[k + i] == -1:
					a[i] = 1
					a[k + i] = 1
				elif a[k + i] == -1:
					a[k + i] = a[i]
				else:
					a[i] = a[k + i]
			print('YES')
			for i in range(n):
				print(a[i], end=' ')
			print('')


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())
while t > 0:
	t -= 1
	n = int(input())
	dis = [int(x) for x in input().split()]
	if n % 2 == 1:
		print('NO')
		continue
	mid = n // 2
	for i in range(mid):
		if dis[i] == -1 and dis[mid + i] == -1:
			dis[i] = dis[i + mid] = 1
		elif dis[i] == -1:
			dis[i] = dis[i + mid]
		elif dis[i + mid] == -1:
			dis[i + mid] = dis[i]
	flag = True
	for i in range(mid):
		if dis[i] != dis[i + mid]:
			flag = False
			print('NO')
			break
	if flag:
		print('YES')
		for i in range(n):
			print(dis[i], end=' ')
		print()


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


def process(lenn):
	n = len(lenn)
	if n % 2 is not 0:
		return False
	change = n // 2
	for i in range(change):
		if lenn[i] != lenn[change + i]:
			if lenn[i] is -1:
				lenn[i] = lenn[change + i]
			elif lenn[change + i] is -1:
				lenn[change + i] = lenn[i]
			else:
				return False
		elif lenn[i] is -1:
			lenn[i] = 1
			lenn[change + i] = 1
	return (True, lenn)
test = int(input())
while test:
	N = int(input())
	len_bt_cities = [int(x) for x in input().split()]
	ans = process(len_bt_cities)
	if not ans:
		print('NO')
	else:
		print('YES')
		for i in len_bt_cities:
			print(i, end=' ')
		print()
	test -= 1


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


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	flag = 0
	if n % 2 == 1:
		print('NO')
		continue
	for i in range(n // 2):
		x = l[i]
		y = l[i + n // 2]
		if x == -1 or y == -1:
			l[i] = max(x, y, 1)
			l[i + n // 2] = l[i]
		elif x != y:
			flag = 1
	if flag == 1:
		print('NO')
	else:
		print('YES')
		for i in l:
			print(i, end=' ')
		print('')


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


from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from collections import defaultdict
import math
from fractions import Fraction as frac
from random import random
cin = stdin.readline

def cout(x):
	stdout.write(str(x) + '\n')

def var(type=int):
	return type(stdin.readline())

def readline(type=int):
	return map(type, stdin.readline().split())

def readlist(type=int):
	return list(map(type, stdin.readline().split()))

def sorted_indexes(arr):
	return sorted(range(len(arr)), key=arr.__getitem__)

def printr(arr):
	[stdout.write(str(x) + ' ') for x in arr]
	cout('')

def find_lt(a, x):
	i = bisect_left(a, x)
	if i:
		return a[i - 1]
	raise ValueError

def find_gt(a, x):
	i = bisect_right(a, x)
	if i != len(a):
		return a[i]
	raise ValueError

def dist(x, y):
	return math.sqrt(x * x + y * y)

def binary_search(arr, x):
	i = bisect_left(arr, x)
	if i == len(arr) or arr[i] != x:
		return -1
	return i
MOD2 = 998244353
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 == 1:
		print('NO')
	else:
		flg = True
		x = n // 2
		for j in range(int(n / 2)):
			if a[j] < 0 and a[j + x] < 0:
				a[j] = 1
				a[j + x] = 1
			elif a[j] < 0 and a[j + x] > 0:
				a[j] = a[j + x]
			elif a[j] > 0 and a[j + x] < 0:
				a[j + x] = a[j]
			elif a[j + x] != a[j] and a[j] > 0:
				flg = False
		if flg:
			print('YES')
			for el in a:
				print(el, end=' ')
			print()
		else:
			print('NO')


test = int(input())
for _ in range(test):
	n = int(input())
	a = list(map(int, input().split()))
	if n % 2 != 0:
		print('NO')
	else:
		t = True
		x = n // 2
		for i in range(n):
			if a[i] == -1:
				if a[i + x] == -1:
					a[i] = 1
					a[(i + x) % n] = 1
				else:
					a[i] = a[(i + x) % n]
			elif a[(i + x) % n] == -1:
				a[(i + x) % n] = a[i]
			elif a[i] != a[(i + x) % n]:
				t = False
				break
		if t:
			print('YES')
			for i in a:
				print(i, end=' ')
			print('')
		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')


def GetLength():
	t = int(input())
	for i in range(t):
		n = int(input())
		A = input().split()
		tup = ''
		if n % 2 != 0:
			print('NO')
			continue
		else:
			for j in range(n // 2):
				if A[j] == '-1' and A[n // 2 + j] != '-1':
					A[j] = A[n // 2 + j]
				elif A[j] != '-1' and A[n // 2 + j] == '-1':
					A[n // 2 + j] = A[j]
				elif A[j] == '-1' and A[n // 2 + j] == '-1':
					A[n // 2 + j] = '1'
					A[j] = '1'
				elif A[j] != A[n // 2 + j]:
					print('NO')
					break
			if A[j] == A[n // 2 + j]:
				print('YES')
				for j in A:
					tup += j + ' '
				print(tup)
GetLength()


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)


t = int(input())
for z in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	flag = 0
	if n % 2 == 0 and n // 2 % 2 == 0:
		for i in range(n - 2):
			if a[i] != -1 and a[i + n // 2] != -1 and (a[i + n // 2] != a[i]):
				flag = 1
				break
			elif a[i] != -1 and a[i + n // 2] == -1:
				a[i + n // 2] = a[i]
			elif a[i] == -1 and a[i + n // 2] == -1:
				a[i] = 1
				a[i + n // 2] = 1
			elif a[i] == -1 and a[i + n // 2] != -1:
				a[i] = a[i + n // 2]
	elif n % 2 == 0:
		k = 1
		for i in a:
			if i != -1:
				k = i
		for i in range(n - n // 2):
			if a[i] != -1 and a[i + n // 2] != -1 and (a[i + n // 2] != a[i]):
				flag = 1
				break
			elif a[i] != -1 and a[i + n // 2] == -1:
				a[i + n // 2] = a[i]
			elif a[i] == -1 and a[i + n // 2] == -1:
				a[i] = k
				a[i + n // 2] = k
			elif a[i] == -1 and a[i + n // 2] != -1:
				a[i] = a[i + n // 2]
	else:
		print('NO')
		continue
	if sum(a) % 2 != 0:
		flag = 1
	if flag == 0:
		print('YES')
		for i in a:
			print(i, end=' ')
		print()
	else:
		print('NO')


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


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


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


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


t = int(input())
for i in range(t):
	n = int(input())
	a = []
	a = list(map(int, input().split(' ')))
	l = n // 2
	flag = 0
	for j in range(n // 2):
		if n % 2 == 1:
			flag = 1
			print('NO')
			break
		if a[j] != a[l + j] and a[j] != -1 and (a[l + j] != -1):
			print('NO')
			flag = 1
			break
		if a[j] != -1 and a[l + j] == -1:
			a[l + j] = a[j]
		if a[j] == -1 and a[l + j] != -1:
			a[j] = a[l + j]
		if a[j] == -1 and a[l + j] == -1:
			a[j] = 1
			a[l + j] = 1
	if flag == 0:
		print('YES')
		for j in range(n):
			print(a[j], end=' ')
		print()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = []
	a2 = []
	for j in range(n // 2):
		a1.append(a[j])
	for j in range(n // 2, n):
		a2.append(a[j])
	if -1 not in a:
		if a1 == a2:
			print('YES')
			for j in range(n):
				print(a[j], end=' ')
			print('')
		else:
			print('NO')
	else:
		for j in range(n // 2):
			if a1[j] == a2[j] == -1:
				a1[j] = 1
				a2[j] = 1
			elif a1[j] == -1:
				a1[j] = a2[j]
			elif a2[j] == -1:
				a2[j] = a1[j]
		if a1 == a2:
			print('YES')
			for j in range(n // 2):
				print(a1[j], end=' ')
			for j in range(n // 2):
				print(a2[j], end=' ')
			print('')
		else:
			print('NO')


n = int(input())
for _ in range(n):
	a = int(input())
	flag = True
	arr = [int(x) for x in input().split()]
	if a % 2 != 0:
		flag = False
		print('NO')
		continue
	for i in range(int(a / 2)):
		x = int(a / 2)
		if arr[i] == arr[i + x] or arr[i] == -1 or arr[i + x] == -1:
			if arr[i] == -1 and arr[i + x] == -1:
				arr[i] = arr[i + x] = 1
			elif arr[i] == -1:
				arr[i] = arr[i + x]
			elif arr[i + x] == -1:
				arr[i + x] = arr[i]
		else:
			flag = False
	if flag == False:
		print('NO')
	else:
		print('YES')
		for i in arr:
			print(i, end=' ')
		print()


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


import time
from sys import stdout, stdin

def myfunction(n, arr):
	if n % 2 != 0:
		print('NO')
		return
	else:
		for i in range(0, n // 2):
			if arr[i] == -1 and arr[i + n // 2] == -1:
				arr[i] = 1
				arr[i + n // 2] = 1
				continue
			elif arr[i] != -1 and arr[i + n // 2] == -1:
				arr[i + n // 2] = arr[i]
				continue
			elif arr[i] == -1 and arr[i + n // 2] != -1:
				arr[i] = arr[i + n // 2]
				continue
			elif arr[i] != arr[n // 2 + i]:
				print('NO')
				break
		else:
			print('YES')
			for i in range(0, n):
				print(arr[i], end=' ')
			print()
t = int(stdin.readline())
while t > 0:
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	myfunction(n, arr)
	t -= 1


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


import bisect

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


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())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = n // 2
	l2 = [0] * n
	for j in range(s):
		if l[j] == l[j + s]:
			(l2[j], l2[j + s]) = (l[j], l[j + s])
		if l[j] == -1 and l[j + s] == -1:
			(l2[j], l2[j + s]) = (1, 1)
		if l[j] == -1 and l[j + s] > 0:
			(l2[j], l2[j + s]) = (l[j + s], l[j + s])
		if l[j + s] == -1 and l[j] > 0:
			(l2[j], l2[j + s]) = (l[j], l[j])
	if 0 in l2:
		print('NO')
	else:
		print('YES')
		for x in l2:
			print(x, end=' ')
		print()


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


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


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:
	t -= 1
	n = int(input())
	a = list(map(int, input().strip().split()))
	if n % 2:
		print('NO')
	else:
		okay = True
		p = n // 2
		for i in range(p):
			if a[i] == -1 and a[i + p] == -1:
				a[i] = a[i + p] = 1
			elif a[i] == -1:
				a[i] = a[i + p]
			elif a[i + p] == -1:
				a[i + p] = a[i]
			elif a[i] != a[i + p]:
				okay = False
		if okay:
			print('YES')
			for x in a:
				print(x, end=' ')
			print()
		else:
			print('NO')


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


from sys import stdin
T = int(stdin.readline())
for _ in range(T):
	N = int(stdin.readline())
	A = [int(x) for x in stdin.readline().split()]
	if N % 2 == 1:
		print('NO')
	elif N % 2 == 0:
		z = N // 2
		result = True
		for i in range(z):
			if A[i] == -1:
				if A[i + z] == -1:
					A[i] = 1
					A[i + z] = 1
				else:
					A[i] = A[i + z]
			elif A[i + z] == -1:
				A[i + z] = A[i]
			elif A[i + z] != A[i]:
				result = False
				break
		if result == True:
			print('YES')
			for i in range(N):
				print(A[i], end=' ')
			print()
		else:
			print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	if n % 2 == 0:
		y = n // 2
		for i in range(y):
			if A[i] == -1:
				A[i] = A[y + i]
			if A[y + i] == -1:
				A[y + i] = A[i]
			if A[i] == -1:
				(A[i], A[y + i]) = (1, 1)
		answer = 0
		for i in range(y):
			if A[i] != A[y + i]:
				answer = 1
				break
		if answer == 0:
			print('YES')
			for i in range(n):
				print(A[i], end=' ')
			print()
		else:
			print('NO')
	else:
		print('NO')


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


def solve():
	half = n // 2
	for i in range(half):
		if a[i] == -1:
			if a[half + i] == -1:
				a[half + i] = 1
			a[i] = a[half + i]
		elif a[half + i] == -1:
			if a[i] == -1:
				a[i] = 1
			a[half + i] = a[i]
		elif a[i] != a[half + i]:
			print('NO')
			return
	print('YES')
	for i in a:
		print(i, end=' ')
	print()
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	if n % 2:
		print('NO')
	else:
		solve()


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)


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


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