Given an array $a=[a_1,a_2,\dots,a_n]$ of $n$ positive integers, you can do operations of two types on it:

Add $1$ to every element with an odd index. In other words change the array as follows: $a_1 := a_1 +1, a_3 := a_3 + 1, a_5 := a_5+1, \dots$.

Add $1$ to every element with an even index. In other words change the array as follows: $a_2 := a_2 +1, a_4 := a_4 + 1, a_6 := a_6+1, \dots$.

Determine if after any number of operations it is possible to make the final array contain only even numbers or only odd numbers. In other words, determine if you can make all elements of the array have the same parity after any number of operations.

Note that you can do operations of both types any number of times (even none). Operations of different types can be performed a different number of times.


-----Input-----

The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases.

The first line of each test case contains an integer $n$ ($2 \leq n \leq 50$) — the length of the array.

The second line of each test case contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \leq a_i \leq 10^3$) — the elements of the array.

Note that after the performed operations the elements in the array can become greater than $10^3$.


-----Output-----

Output $t$ lines, each of which contains the answer to the corresponding test case. As an answer, output "YES" if after any number of operations it is possible to make the final array contain only even numbers or only odd numbers, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).


-----Examples-----

Input
4
3
1 2 1
4
2 2 2 3
4
2 2 2 2
5
1000 1 1000 1 1000
Output
YES
NO
YES
YES


-----Note-----

For the first test case, we can increment the elements with an even index, obtaining the array $[1, 3, 1]$, which contains only odd numbers, so the answer is "YES".

For the second test case, we can show that after performing any number of operations we won't be able to make all elements have the same parity, so the answer is "NO".

For the third test case, all elements already have the same parity so the answer is "YES".

For the fourth test case, we can perform one operation and increase all elements at odd positions by $1$, thus obtaining the array $[1001, 1, 1001, 1, 1001]$, and all elements become odd so the answer is "YES".

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation

Greedy algorithms


Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	poss = True
	par = a[0] % 2
	for i in range(2, n, 2):
		pari = a[i] % 2
		if par != pari:
			poss = False
	par = a[1] % 2
	for i in range(1, n, 2):
		pari = a[i] % 2
		if par != pari:
			poss = False
	if poss:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	if n < 3:
		print('YES')
	else:
		evenindex = l[0] % 2
		oddindex = l[1] % 2
		for i in range(2, n):
			if i % 2 == 0:
				if l[i] % 2 != evenindex:
					print('NO')
					break
			elif l[i] % 2 != oddindex:
				print('NO')
				break
		else:
			print('YES')
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	even = []
	odd = []
	flag = 0
	flag1 = 0
	e = 0
	o = 0
	for i in range(n):
		if i & 1:
			odd.append(arr[i])
		else:
			even.append(arr[i])
	for i in even:
		if i & 1:
			if e:
				flag = 1
				break
			o += 1
		else:
			if o:
				flag = 1
				break
			e += 1
	e = 0
	o = 0
	for i in odd:
		if i & 1:
			if e:
				flag1 = 1
				break
			o += 1
		else:
			if o:
				flag1 = 1
				break
			e += 1
	if flag or flag1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	k = list(map(int, input().split()))
	co1 = 0
	co2 = 0
	ce1 = 0
	ce2 = 0
	for i in range(n):
		if i % 2 == 0:
			if k[i] % 2 == 0:
				co1 += 1
			else:
				co2 += 1
		elif k[i] % 2 == 0:
			ce1 += 1
		else:
			ce2 += 1
	if (co1 == 0 or co2 == 0) and (ce1 == 0 or ce2 == 0):
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
tc = []
for _ in range(t):
	n = int(input())
	even = []
	odd = []
	arr = list(map(int, input().strip().split()))
	res = all((arr[idx] % 2 == 0 for idx in range(0, len(arr))))
	res_ = all((arr[idx] % 2 == 1 for idx in range(0, len(arr))))
	if res or res_:
		print('YES')
	else:
		for i in range(n):
			if i % 2 == 0:
				even.append(arr[i])
			else:
				odd.append(arr[i])
		res = all((even[idx] % 2 == 0 for idx in range(0, len(even))))
		res_ = all((odd[idx] % 2 == 1 for idx in range(0, len(odd))))
		res1 = all((even[idx] % 2 == 1 for idx in range(0, len(even))))
		res1_ = all((odd[idx] % 2 == 0 for idx in range(0, len(odd))))
		if res and res_ or (res1 and res1_):
			print('YES')
		else:
			print('NO')


t = int(input())
otv = ['YES'] * t
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	g1 = a[0] % 2
	g2 = a[1] % 2
	for i in range(0, n, 2):
		if a[i] % 2 != g1:
			otv[T] = 'NO'
			break
	for i in range(1, n, 2):
		if a[i] % 2 != g2:
			otv[T] = 'NO'
			break
for i in range(t):
	print(otv[i])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split(' ')]
	first = a[0] % 2
	second = a[1] % 2
	ans = 'YES'
	for i in range(n):
		if i % 2 == 0 and a[i] % 2 == first:
			continue
		if i % 2 == 1 and a[i] % 2 == second:
			continue
		ans = 'NO'
		break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	f1 = arr[0] % 2
	f2 = arr[1] % 2
	res = True
	for i in arr[::2]:
		if i % 2 != f1:
			res = False
			break
	for i in arr[1::2]:
		if i % 2 != f2:
			res = False
			break
	if res:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	op = l[1] % 2
	ep = l[0] % 2
	ans = 'YES'
	for i in range(n):
		if i % 2 == 0 and l[i] % 2 != ep:
			ans = 'NO'
			break
		if i % 2 == 1 and l[i] % 2 != op:
			ans = 'NO'
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = a[0] % 2
	q = a[1] % 2
	flag = True
	for i in range(3, n, 2):
		if a[i] % 2 != q:
			flag = False
			break
	for i in range(2, n, 2):
		if a[i] % 2 != p:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	(o, e) = (set(), set())
	for i in range(n):
		if i % 2 == 0:
			e.add(A[i] % 2)
		else:
			o.add(A[i] % 2)
	if len(o) == 1 and len(e) == 1:
		print('YES')
	else:
		print('NO')


from math import ceil
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = sum([1 for i in range(n) if i % 2 == 0 and a[i] % 2 == 0])
	y = sum([1 for i in range(n) if i % 2 == 1 and a[i] % 2 == 0])
	if x == 0 or x == ceil(n / 2):
		if y == 0 or y == n // 2:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


import collections
import sys
from collections import Counter, deque
import heapq
import bisect
import copy
MOD = 1000000007
NO = lambda : print('NO')
YES = lambda : print('YES')
_1 = lambda : print(-1)
ari = lambda : [int(_) for _ in input().split()]
cin = lambda : int(input())
cis = lambda : input()
show = lambda x: print(x)
fast = lambda : sys.stdin.readline()
test_case = 1
test_case = int(input())
sys.setrecursionlimit(10 ** 6)

def ans():
	n = cin()
	arr = ari()
	odd = []
	even = []
	for i in range(n):
		if (i + 1) % 2:
			odd.append(arr[i])
		else:
			even.append(arr[i])
	k = 0
	p = 0
	for i in odd:
		if i % 2:
			k += 1
		else:
			p += 1
	k1 = 0
	p1 = 0
	for i in even:
		if i % 2:
			k1 += 1
		else:
			p1 += 1
	if (k1 == len(even) or p1 == len(even)) and (k == len(odd) or p == len(odd)):
		print('YES')
	else:
		print('NO')
	return
for _ in range(test_case):
	ans()


x = int(input())
for i in range(x):
	n = int(input())
	s1 = input()
	arr1 = [int(l) for l in s1.split(' ')]
	e1 = True
	if arr1[0] % 2 == 0:
		for j in range(0, n, 2):
			if arr1[j] % 2 == 1:
				e1 = False
			else:
				pass
	elif arr1[0] % 2 == 1:
		for j in range(0, n, 2):
			if arr1[j] % 2 == 0:
				e1 = False
			else:
				pass
	if arr1[1] % 2 == 0:
		for j in range(1, n, 2):
			if arr1[j] % 2 == 1:
				e1 = False
			else:
				pass
	elif arr1[1] % 2 == 1:
		for j in range(1, n, 2):
			if arr1[j] % 2 == 0:
				e1 = False
			else:
				pass
	if e1 == True:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	(odd, even) = (0, 0)
	for num in nums:
		if num % 2 == 0:
			even += 1
		else:
			odd += 1
	if odd == len(nums) or even == len(nums):
		print('YES')
		continue
	(odd, even) = (0, 0)
	for (j, num) in enumerate(nums):
		temp = num
		if j % 2 == 0:
			temp += 1
		if temp % 2 == 0:
			even += 1
		else:
			odd += 1
	if odd == len(nums) or even == len(nums):
		print('YES')
		continue
	(odd, even) = (0, 0)
	for (j, num) in enumerate(nums):
		temp = num
		if j % 2 == 1:
			temp += 1
		if temp % 2 == 0:
			even += 1
		else:
			odd += 1
	if odd == len(nums) or even == len(nums):
		print('YES')
		continue
	print('NO')


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


t = int(input())
for i1 in range(t):
	n = int(input())
	array = [int(i2) for i2 in input().split()]
	odd_parity = array[0] % 2
	even_parity = array[1] % 2
	flag = False
	for i2 in range(0, n, 2):
		if array[i2] % 2 != odd_parity:
			flag = True
			break
	for i2 in range(1, n, 2):
		if array[i2] % 2 != even_parity:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	n1 = li[0] % 2
	n2 = li[1] % 2
	chk = 0
	for i in range(2, n):
		if i % 2 == 0 and n1 != li[i] % 2:
			chk = 1
		elif i % 2 == 1 and n2 != li[i] % 2:
			chk = 1
	if chk == 0:
		print('YES')
	else:
		print('NO')


t = int(input())

def f(arr):
	n = len(arr)
	if n <= 2:
		return 'YES'
	e = arr[0]
	o = arr[1]
	for i in range(n):
		if i % 2 == 0:
			if (arr[i] - e) % 2 != 0:
				return 'NO'
		elif (arr[i] - o) % 2 != 0:
			return 'NO'
	return 'YES'
for i in range(t):
	n = int(input())
	line = input()
	arr = [int(j) for j in line.split()]
	print(f(arr))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	answer = 'YES'
	if len(arr) > 2:
		a = arr[0] % 2
		b = arr[1] % 2
		for (i, x) in enumerate(arr):
			if i % 2 == 0 and x % 2 != a or (i % 2 == 1 and x % 2 != b):
				answer = 'NO'
				break
	print(answer)


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	odd = list()
	even = list()
	for i in range(n):
		if i % 2 == 0:
			odd.append(a[i])
		else:
			even.append(a[i])
	o = len(odd)
	e = len(even)
	k = 0
	for i in range(o - 1):
		if (odd[i] + odd[i + 1]) % 2 == 0:
			continue
		else:
			k = 1
			break
	for i in range(e - 1):
		if k == 1:
			break
		elif (even[i] + even[i - 1]) % 2 == 0:
			continue
		else:
			k = 1
			break
	if k == 1:
		print('NO')
	else:
		print('YES')
	t = t - 1


from sys import stdin

def check(arr, n):
	even = 0
	odd = 0
	for i in arr:
		if i % 2 == 0:
			even += 1
		else:
			odd += 1
	if even == n or odd == n:
		return True
	return False

def solve(arr, n):
	first = check(arr, n)
	if first == True:
		return True
	a1 = arr.copy()
	for i in range(n):
		if i % 2 == 0:
			a1[i] = a1[i] + 1
	second = check(a1, n)
	if second == True:
		return True
	a2 = arr.copy()
	for i in range(n):
		if i % 2 != 0:
			a2[i] = a2[i] + 1
	third = check(a2, n)
	if third == True:
		return True
	return False
t = int(stdin.readline().strip())
for i in range(t):
	n = int(stdin.readline().strip())
	arr = [int(i) for i in stdin.readline().split()]
	if solve(arr, n):
		print('YES')
	else:
		print('NO')


T = int(input())
for K in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	(c1, c2) = ('x', 'x')
	if a[0] % 2 != 0:
		c1 = 'o'
	else:
		c1 = 'e'
	if a[1] % 2 != 0:
		c2 = 'o'
	else:
		c2 = 'e'
	if c1 == 'e' and c2 == 'e':
		for i in range(n):
			if a[i] % 2 != 0:
				print('NO')
				f = 1
				break
	elif c1 == 'o' and c2 == 'o':
		for i in range(n):
			if a[i] % 2 == 0:
				print('NO')
				f = 1
				break
	elif c1 == 'e' and c2 == 'o':
		for i in range(n):
			if i % 2 == 0:
				if a[i] % 2 != 0:
					print('NO')
					f = 1
					break
			elif a[i] % 2 == 0:
				print('NO')
				f = 1
				break
	elif c1 == 'o' and c2 == 'e':
		for i in range(n):
			if i % 2 == 0:
				if a[i] % 2 == 0:
					print('NO')
					f = 1
					break
			elif a[i] % 2 != 0:
				print('NO')
				f = 1
				break
	if f == 0:
		print('YES')


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


t = int(input())
ans = list()
for i in range(0, t):
	n = int(input())
	l = [int(x) for x in input().split()]
	j = 0
	d = 0
	while j < n:
		if (l[j] - l[0]) % 2 != 0:
			d = 1
			break
		j += 2
	j = 1
	if d == 1:
		ans.append('NO')
		continue
	while j < n:
		if (l[j] - l[1]) % 2 != 0:
			d = 1
			break
		j += 2
	if d == 1:
		ans.append('NO')
		continue
	ans.append('YES')
	continue
for s in ans:
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = [[0, 0], [0, 0]]
	for i in range(n):
		cnt[i % 2][arr[i] % 2] += 1
	if min(cnt[0]) != 0 or min(cnt[1]) != 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(0, t):
	a = int(input())
	b = list(map(int, input().split()))
	count = 0
	num = 0
	count1 = 0
	num1 = 0
	odd = 0
	for ele in range(0, len(b)):
		if (ele + 1) % 2 == 0:
			if b[ele] % 2 == 0:
				count += 1
			else:
				num += 1
		elif b[ele] % 2 == 0:
			count1 += 1
		else:
			num1 += 1
	if len(b) % 2 == 0:
		even = len(b) // 2
		odd = len(b) // 2
	else:
		odd = len(b) // 2 + 1
		even = len(b) - odd
	if even == count1 and (odd == count or odd == num or odd == num1):
		print('YES')
	elif even == count and (odd == num or odd == count1 or odd == num1):
		print('YES')
	elif even == num1 and (odd == count or odd == num or odd == count1):
		print('YES')
	elif even == num and (odd == count or odd == count1 or odd == num1):
		print('YES')
	else:
		print('NO')


n = int(input())
L = []
for i in range(n):
	n = int(input())
	L1 = list(map(int, input().split()))
	L.append(L1)
for i in L:
	mark = 0
	m1 = i[::2]
	m2 = i[1::2]
	m1 = set(m1)
	m2 = set(m2)
	l1 = []
	l2 = []
	for k in m1:
		if k % 2 == 0:
			l1.append(1)
		else:
			l1.append(-1)
	for k in m2:
		if k % 2 == 0:
			l2.append(1)
		else:
			l2.append(-1)
	if len(set(l1)) <= 1 and len(set(l2)) <= 1:
		print('YES')
	else:
		print('NO')


import sys

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

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

def main():
	for _ in range(int(input())):
		n = int(input())
		a = get_ls()
		odd = list()
		even = list()
		for i in range(n):
			if i % 2 == 0:
				even.append(a[i])
			if i % 2 == 1:
				odd.append(a[i])
		ok = True
		for i in range(len(even) - 1):
			if even[i] % 2 != even[i + 1] % 2:
				ok = False
		for i in range(len(odd) - 1):
			if odd[i] % 2 != odd[i + 1] % 2:
				ok = False
		if ok:
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	count = 0
	counterC = 0
	for j in range(0, n):
		if a[j] % 2 == 0:
			count += 1
	if count == len(a) or count == 0:
		print('YES')
	else:
		for j in range(0, n, 2):
			a[j] += 1
		for j in range(0, n):
			if a[j] % 2 == 0:
				counterC += 1
		if counterC == len(a) or counterC == 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = a[0] % 2
	c = a[1] % 2
	for i in range(len(a)):
		if i % 2 == 0:
			a[i] = a[i] % 2 == b
		else:
			a[i] = a[i] % 2 == c
	print('YES' if all(a) else 'NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	flag1 = 1
	flag2 = 1
	a = l[0] % 2
	b = l[1] % 2
	for i in range(2, n, 2):
		if l[i] % 2 != a:
			flag1 = 0
			break
	for i in range(3, n, 2):
		if l[i] % 2 != b:
			flag2 = 0
			break
	if flag1 == 1 and flag2 == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	odd = a[1::2]
	even = a[::2]
	if all(map(lambda x: x % 2 == odd[0] % 2, odd)) and all(map(lambda x: x % 2 == even[0] % 2, even)):
		print('YES')
	else:
		print('NO')


test_cases = int(input())
for i in range(test_cases):
	c = 0
	k = 0
	lenght = int(input())
	even = 0
	odd = 0
	odd1 = 0
	even1 = 0
	l1 = [int(x) for x in input().split()]
	for i in range(1, lenght, 2):
		if l1[i] % 2 != 0:
			odd += 1
		else:
			even += 1
		if odd != 0 and even != 0:
			print('NO')
			k = 1
			break
	else:
		c = 1
	if k == 1:
		continue
	for i in range(0, lenght, 2):
		if l1[i] % 2 != 0:
			odd1 += 1
		else:
			even1 += 1
		if odd1 != 0 and even1 != 0:
			print('NO')
			break
	else:
		if odd != 0 and even1 != 0:
			print('YES')
		elif odd1 != 0 and even != 0:
			print('YES')
		elif odd != 0 and odd1 != 0:
			print('YES')
		elif even != 0 and even1 != 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	a = l[::2]
	b = l[1::2]
	flag = 0
	for i in range(len(a) - 1):
		if a[i] % 2 == 0 and a[i + 1] % 2 != 0 or (a[i] % 2 != 0 and a[i + 1] % 2 == 0):
			flag = 1
			break
	if flag == 0:
		for i in range(len(b) - 1):
			if b[i] % 2 == 0 and b[i + 1] % 2 != 0 or (b[i] % 2 != 0 and b[i + 1] % 2 == 0):
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = a[1::2]
	e = a[::2]
	b = d[0] % 2
	c = e[0] % 2
	count1 = 0
	count2 = 0
	for elem in d:
		if elem % 2 != b:
			count1 = 1
			break
	for elem in e:
		if elem % 2 != c:
			count2 = 1
			break
	if count1 == 1 or count2 == 1:
		print('NO')
	elif count1 == 0 and count2 == 0:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	sum = 0
	for num in arr:
		if num % 2 == 1:
			sum += 1
	if sum == n or sum == 0:
		print('YES')
	else:
		arr_odd = []
		arr_even = []
		for (i, num) in enumerate(arr):
			if i % 2 == 0:
				arr_odd.append(num)
			else:
				arr_even.append(num)
		parity_odd = 'ODD'
		parity_even = 'ODD'
		parity_odd_1 = []
		parity_even_1 = []
		if arr_odd[0] % 2 == 0:
			parity_odd = 'EVEN'
		if arr_even[0] % 2 == 0:
			parity_even = 'EVEN'
		for i in range(2, n):
			if i % 2 == 0:
				if arr[i] % 2 == 0:
					parity_odd_1.append('EVEN')
				else:
					parity_odd_1.append('ODD')
			elif arr[i] % 2 == 0:
				parity_even_1.append('EVEN')
			else:
				parity_even_1.append('ODD')
		if all((parity_even == parity for parity in parity_even_1)):
			if all((parity_odd == parity for parity in parity_odd_1)):
				if parity_even != parity_odd:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')


t = int(input())
for l in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	f1 = 0
	f2 = 0
	for i in range(2, n, 2):
		if li[i] % 2 != li[0] % 2:
			f2 = 1
	for i in range(3, n, 2):
		if li[i] % 2 != li[1] % 2:
			f1 = 1
	if f1 == 0 and f2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ch0 = a[0] % 2
	ch1 = a[1] % 2
	c = 0
	for i in range(len(a)):
		if i % 2 == 0 and a[i] % 2 != ch0 or (i % 2 == 1 and a[i] % 2 != ch1):
			c = 1
			print('NO')
			break
	if c == 0:
		print('YES')


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print('YES')
		continue
	odd = 0
	eve = 0
	for i in range(0, n, 2):
		if a[i] % 2 == 0:
			eve += 1
		else:
			odd += 1
	neve = n - n // 2
	if odd != neve and eve != neve:
		print('NO')
		continue
	odd = 0
	eve = 0
	for i in range(1, n, 2):
		if a[i] % 2 == 0:
			eve += 1
		else:
			odd += 1
	nodd = n // 2
	if odd != nodd and eve != nodd:
		print('NO')
		continue
	print('YES')


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = True
	odd_index_even = 0
	odd_index_odd = 0
	even_index_even = 0
	even_index_odd = 0
	for i in range(1, n + 1):
		if i % 2 != 0 and a[i - 1] % 2 == 0:
			odd_index_even += 1
		elif i % 2 != 0 and a[i - 1] % 2 != 0:
			odd_index_odd += 1
		elif i % 2 == 0 and a[i - 1] % 2 == 0:
			even_index_even += 1
		elif i % 2 == 0 and a[i - 1] % 2 != 0:
			even_index_odd += 1
	if odd_index_even > 0 and odd_index_odd > 0:
		print('NO')
	elif even_index_odd > 0 and even_index_even > 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	count = 0
	pount = 0
	for i in l:
		l1.append(i)
	ce1 = 0
	ce2 = 0
	co1 = 0
	co2 = 0
	for i in l:
		if i % 2 == 0:
			count += 1
		else:
			pount += 1
	if count == n or pount == n:
		print('YES')
	else:
		for i in range(n):
			if i % 2 == 0:
				l[i] += 1
		for i in l:
			if i % 2 == 0:
				ce1 += 1
			else:
				co1 += 1
		for i in range(n):
			if i % 2 != 0:
				l1[i] += 1
		for i in l1:
			if i % 2 != 0:
				co2 += 1
			else:
				ce2 += 1
		if ce1 == n or co1 == n:
			print('YES')
		elif ce2 == n or co2 == n:
			print('YES')
		else:
			print('NO')
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	flag1 = True
	l = list(map(int, input().split()))
	for i in l:
		if i % 2 != 0:
			flag1 = False
			break
	flag2 = True
	for i in l:
		if i % 2 == 0:
			flag2 = False
			break
	flag3 = True
	for i in range(0, n, 2):
		if i + 1 < n and l[i] % 2 == 0 and (l[i + 1] % 2 == 0) or (i + 1 < n and l[i] % 2 == 1 and (l[i + 1] % 2 == 1)):
			flag3 = False
	if l[-1] % 2 == 0 and l[-2] % 2 == 0 or (l[-1] % 2 == 1 and l[-2] % 2 == 1):
		flag3 = False
	if flag1 or flag2 or flag3:
		print('YES')
	else:
		print('NO')


t = int(input())
for q in range(t):
	n = int(input())
	Q = list(map(int, input().split()))
	f = True
	Evens = []
	Odds = []
	for i in range(n):
		if i % 2 == 0:
			Evens.append(Q[i])
		else:
			Odds.append(Q[i])
	if n > 2:
		for i in range(len(Evens) - 1):
			if Evens[i] % 2 == 0 and Evens[i + 1] % 2 != 0:
				print('NO')
				f = False
				break
			if Evens[i] % 2 != 0 and Evens[i + 1] % 2 == 0:
				print('NO')
				f = False
				break
		if f == True:
			for i in range(len(Odds) - 1):
				if Odds[i] % 2 == 0 and Odds[i + 1] % 2 != 0:
					print('NO')
					break
				if Odds[i] % 2 != 0 and Odds[i + 1] % 2 == 0:
					print('NO')
					break
			else:
				print('YES')
	else:
		print('YES')


t = int(input(''))
for z in range(t):
	b = []
	c = []
	d = 0
	e = 0
	f = 0
	n = int(input(''))
	a = list(map(int, input('').split()))[:n]
	for i in range(0, len(a), 2):
		b.append(a[i])
	for j in range(1, len(a), 2):
		c.append(a[j])
	for k in b:
		if k % 2 == 0:
			d += 1
		else:
			e += 1
	if d == len(b):
		f += 1
	elif e == len(b):
		f += 1
	d = 0
	e = 0
	for l in c:
		if l % 2 == 0:
			d += 1
		else:
			e += 1
	if d == len(c):
		f += 1
	elif e == len(c):
		f += 1
	if f == 2:
		print('YES')
	else:
		print('NO')


def f(L):
	n = len(L)
	r = L[0] % 2
	for i in range(0, n, 2):
		if L[i] % 2 != r:
			return 'NO'
	r = L[1] % 2
	for i in range(1, n, 2):
		if L[i] % 2 != r:
			return 'NO'
	return 'YES'
x = int(input())
for j in range(x):
	y = int(input())
	L = list(map(int, input().split()))
	print(f(L))


for _ in range(int(input())):
	n = int(input())
	k = list(map(int, input().split()))
	oe = 0
	oo = 0
	eo = 0
	ee = 0
	for i in range(len(k)):
		if i & 1 == 0:
			if k[i] & 1 == 0:
				oe += 1
			else:
				oo += 1
		elif k[i] & 1 == 0:
			ee += 1
		else:
			eo += 1
	if ee > 0 and eo > 0 or (oo > 0 and oe > 0):
		print('NO')
	else:
		print('YES')


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	(e1, o1, e2, o2) = (False, False, False, False)
	for i in range(n):
		if i % 2 == 0:
			if arr[i] % 2 == 0:
				e1 = True
			else:
				o1 = True
		elif arr[i] % 2 == 0:
			e2 = True
		else:
			o2 = True
		if e1 and o1 or (e2 and o2):
			return 'NO'
	return 'YES'
for i in range(int(input())):
	print(solve())


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = 0
	u = 0
	sum = 0
	count = 0
	for i in range(n):
		if i % 2 == 0:
			if a[i] % 2 == 0:
				count += 1
			else:
				sum += 1
		elif a[i] % 2 == 0:
			f += 1
		else:
			u += 1
	if sum > 0 and count > 0:
		print('NO')
	elif f > 0 and u > 0:
		print('NO')
	else:
		print('YES')


import collections
x = int(input())

def cal(n, arr):
	a = arr[0] % 2
	b = arr[1] % 2
	for i in range(0, n, 2):
		if arr[i] % 2 != a:
			return 'NO'
	for i in range(1, n, 2):
		if arr[i] % 2 != b:
			return 'NO'
	return 'YES'
for jj in range(x):
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	if n <= 2:
		print('YES')
	elif n == 3:
		if arr[0] % 2 == arr[2] % 2:
			print('YES')
		else:
			print('NO')
	else:
		print(cal(n, arr))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	oe = False
	oo = False
	eo = False
	ee = False
	for x in range(0, len(l), 2):
		if l[x] % 2 == 0:
			ee = True
		else:
			eo = True
	for x in range(1, len(l), 2):
		if l[x] % 2 == 0:
			oe = True
		else:
			oo = True
	if ee & eo or oe & oo:
		print('NO')
	else:
		print('YES')


T = int(input())
for i in range(T):
	n = int(input())
	ar = list(map(int, input().split()))
	o_o = 0
	o_e = 0
	e_o = 0
	e_e = 0
	o = 0
	e = 0
	for j in range(n):
		if j % 2 == 0:
			e += 1
			if ar[j] % 2 == 0:
				e_e += 1
			else:
				e_o += 1
		else:
			o += 1
			if ar[j] % 2 == 0:
				o_e += 1
			else:
				o_o += 1
	if (o_o == o or o_e == o) and (e_e == e or e_o == e):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	sz = len(lst)
	res = [0] * sz
	for i in range(sz):
		if lst[i] & 1:
			res[i] = 1
	if res.count(0) == sz or res.count(1) == sz:
		print('YES')
		continue
	stat = True
	for i in range(sz - 1):
		if res[i] == res[i + 1]:
			stat = False
			break
	print('YES' if stat else 'NO')


tc = int(input())
for _ in range(tc):
	n = int(input())
	a = list(map(int, input().split()))
	odd = all((True if i % 2 == a[0] % 2 else False for i in a[::2]))
	even = all((True if i % 2 == a[1] % 2 else False for i in a[1::2]))
	print('YES' if odd and even else 'NO')


import math

def func(N, arr):
	i = 0
	while i < N:
		if arr[0] % 2 != arr[i] % 2:
			return 'NO'
		i += 2
	i = 1
	while i < N:
		if arr[1] % 2 != arr[i] % 2:
			return 'NO'
		i += 2
	return 'YES'
	pass
T = int(input())
for i in range(T):
	N = int(input())
	arr = list(map(int, input().split()))
	print(func(N, arr))


import collections
import math
import sys

def main():
	r = int(input())
	a = list(map(int, input().split()))
	odds = []
	evens = []
	for i in range(r):
		if i % 2 == 0:
			evens.append(a[i] % 2)
		else:
			odds.append(a[i] % 2)
	if (sum(evens) == 0 or sum(evens) == len(evens)) and (sum(odds) == 0 or sum(odds) == len(odds)):
		print('YES')
	else:
		print('NO')
t = int(input())
while t > 0:
	main()
	t -= 1


import math, bisect, heapq, random, sys, itertools
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def gprint(t, ans=''):
	print(f'Case #{t + 1}:', ans)
ints = lambda : list(map(int, input().split()))
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
p2 = [1]
p = 10 ** 9 + 7
ANS = []
for t in range(int(input())):
	n = int(input())
	a = ints()
	(o, e) = (set(), set())
	for i in range(n):
		if i % 2:
			o.add(a[i] % 2)
		else:
			e.add(a[i] % 2)
	if len(o) == 1 and len(e) == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ok = True
	for d in (0, 1):
		for i in range(d + 2, n, 2):
			ok &= a[i] & 1 == a[i - 2] & 1
	print('YES' if ok else 'NO')


import math
for __ in range(int(input())):
	a = int(input())
	bb = list(map(int, input().split()))
	a = bb[0] % 2
	b = bb[1] % 2
	n = 0
	for i in range(2, len(bb)):
		if i % 2 == 0:
			if bb[i] % 2 != a:
				print('NO')
				n = 1
				break
		elif bb[i] % 2 != b:
			print('NO')
			n = 1
			break
	if n == 0:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	e = 0
	if lst[0] % 2 == 0:
		for j in range(2, n, 2):
			if lst[j] % 2 != 0:
				e += 1
				break
	else:
		for j in range(2, n, 2):
			if lst[j] % 2 == 0:
				e += 1
				break
	if lst[1] % 2 == 0:
		for j in range(3, n, 2):
			if lst[j] % 2 != 0:
				e += 1
				break
	else:
		for j in range(3, n, 2):
			if lst[j] % 2 == 0:
				e += 1
				break
	if e == 0:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	for i in range(n):
		if a[i] % 2 != a[i % 2] % 2:
			print('NO')
			break
	else:
		print('YES')
t = int(input())
for _ in range(t):
	solve()


import math

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	for i in range(0, n, 2):
		if arr[0] % 2 != arr[i] % 2:
			print('NO')
			return
	for i in range(1, n, 2):
		if arr[1] % 2 != arr[i] % 2:
			print('NO')
			return
	print('YES')
t = int(input())
for i in range(t):
	solve()


import math
t = int(input())
for vvod in range(t):
	ans = 'YES'
	n = int(input())
	l = list(map(int, input().split()))
	d = dict()
	c1 = l[0] % 2
	c2 = l[1] % 2
	for i in range(n):
		if i % 2 == 1:
			if l[i] % 2 != c2:
				ans = 'NO'
				break
		elif l[i] % 2 != c1:
			ans = 'NO'
			break
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	a = [int(x) for x in input().split()]
	x = a[0] % 2
	y = a[1] % 2
	flag = True
	for i in range(n):
		if i % 2 == 0:
			if a[i] % 2 != x:
				flag = False
				break
		elif a[i] % 2 != y:
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	array = map(int, input().split())
	state = [None, None]
	for (index, value) in enumerate(array):
		mod = index % 2
		e = value % 2
		if state[mod] is None:
			state[mod] = e
		if e != state[mod]:
			print('NO')
			break
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	even = a[::2]
	odd = a[1::2]
	if all((num % 2 == even[0] % 2 for num in even)) and all((num % 2 == odd[0] % 2 for num in odd)):
		print('YES')
	else:
		print('NO')


from collections import defaultdict

def fun(l, n):
	c = l[0] % 2
	d = l[1] % 2
	for i in range(2, n, 2):
		if l[i] % 2 != c:
			return 'NO'
	for i in range(1, n, 2):
		if l[i] % 2 != d:
			return 'NO'
	return 'YES'
tc = int(input())
for _ in range(1, tc + 1):
	n = int(input())
	l = list(map(int, input().split()))
	f = defaultdict(int)
	print(fun(l, n))


import math
c = int(input())
for _ in range(c):
	l = int(input())
	arr = list(map(int, input().split()))
	h1 = sum([x % 2 for x in arr[0::2]])
	h2 = sum([x % 2 for x in arr[1::2]])
	if (h1 == 0 or h1 == math.ceil(l / 2)) and (h2 == 0 or h2 == l // 2):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = []
	a2 = []
	for j in range(n):
		if (j + 1) % 2 == 1:
			a1.append(a[j] % 2)
		else:
			a2.append(a[j] % 2)
	if (sum(a1) == len(a1) or sum(a1) == 0) and (sum(a2) == 0 or sum(a2) == len(a2)):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	ans = True
	n = int(input())
	c1 = -1
	c0 = -1
	k = 0
	for i in input().split():
		if k % 2:
			if c1 == -1:
				c1 = abs(int(i)) % 2
			elif c1 != abs(int(i)) % 2:
				ans = False
				break
		if not k % 2:
			if c0 == -1:
				c0 = abs(int(i)) % 2
			elif c0 != abs(int(i)) % 2:
				ans = False
				break
		k += 1
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	if a[0] % 2 == 0:
		pe = 0
	else:
		pe = 1
	if a[1] % 2 == 0:
		po = 0
	else:
		po = 1
	f = 0
	for i in range(n):
		if i % 2 == 0:
			if a[i] % 2 != pe:
				f = 1
				break
		elif a[i] % 2 != po:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(l, m) = ([], [])
	for i in range(n):
		if i % 2 == 0:
			l.append(a[i])
		else:
			m.append(a[i])
	f = 0
	for i in range(1, len(l)):
		if l[i - 1] % 2 != l[i] % 2:
			f = 1
			break
	if f == 0:
		for i in range(1, len(m)):
			if m[i - 1] % 2 != m[i] % 2:
				f = 1
				break
	if f == 1:
		print('NO')
	else:
		print('YES')


import sys
t = int(input())
for i in range(t):
	a = int(input())
	v = input().split()
	x1 = 0
	x2 = 0
	c1 = 0
	c2 = 0
	end = 0
	for j in range(a):
		if end == 0:
			if j % 2 == 0:
				c1 += 1
				x1 += int(v[j]) % 2 == 0
				if x1 != 0 and x1 != c1:
					print('NO')
					end = 1
			else:
				c2 += 1
				x2 += int(v[j]) % 2 == 0
				if x2 != 0 and x2 != c2:
					print('NO')
					end = 1
	if end == 0:
		print('YES')


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	a = l[0] % 2
	b = l[1] % 2
	for i in range(n):
		if i % 2 == 0:
			if l[i] % 2 == a:
				continue
			else:
				print('NO')
				break
		elif l[i] % 2 == b:
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


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


def Solve():
	n = int(input())
	a = list(map(int, input().split()))
	c = 0
	d = 0
	for i in range(2, len(a), 2):
		if a[i] % 2 != a[i - 2] % 2:
			c = 1
			break
	for i in range(3, len(a), 2):
		if a[i] % 2 != a[i - 2] % 2:
			d = 1
			break
	if c == 0 and d == 0:
		print('YES')
	else:
		print('NO')
q = int(input())
while q > 0:
	Solve()
	q = q - 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = input().split()
	for k in range(n):
		a[k] = int(a[k])
	m = 0
	mm = 0
	for k in range(n - 2):
		if a[k] % 2 != a[k + 2] % 2:
			m = 1
	if m == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f1 = a[0] % 2
	f2 = a[1] % 2
	flag = 0
	for i in range(2, len(a)):
		if i % 2 == 0 and a[i] % 2 != f1:
			print('NO')
			flag = 1
			break
		elif i % 2 == 1 and a[i] % 2 != f2:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c1 = b[0] % 2
	c2 = b[1] % 2
	f = 0
	for i in range(a):
		if i % 2 == 0:
			if b[i] % 2 != c1:
				print('NO')
				f = 1
				break
		elif b[i] % 2 != c2:
			print('NO')
			f = 1
			break
	if f == 0:
		print('YES')


def exe():
	(o1, e1) = (0, 0)
	for i in lst[::2]:
		if i % 2 == 0:
			e1 += 1
		else:
			o1 += 1
	(o2, e2) = (0, 0)
	if min(o1, e1) != 0:
		return 'NO'
	for i in lst[1::2]:
		if i % 2 == 0:
			e2 += 1
		else:
			o2 += 1
	if min(o1, e1) == 0 and min(o2, e2) == 0:
		return 'YES'
	else:
		return 'NO'
for i in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	print(exe())


import sys

def get_numbers():
	return map(int, sys.stdin.readline().strip().split())
t = int(input())
for i in range(t):
	n = int(input())
	numbers = list(get_numbers())
	if numbers[0] % 2 == 0:
		even_indexes = 'even'
	else:
		even_indexes = 'odd'
	if numbers[1] % 2 == 0:
		odd_indexes = 'even'
	else:
		odd_indexes = 'odd'
	wrong = False
	for (ind, number) in enumerate(numbers):
		if ind > 1:
			if ind % 2 == 0:
				if number % 2 == 0 and even_indexes == 'even':
					continue
				elif number % 2 == 1 and even_indexes == 'odd':
					continue
				else:
					wrong = True
					break
			if ind % 2 == 1:
				if number % 2 == 0 and odd_indexes == 'even':
					continue
				elif number % 2 == 1 and odd_indexes == 'odd':
					continue
				else:
					wrong = True
					break
	if wrong:
		print('NO')
	else:
		print('YES')


T = int(input())

def solve(l):
	m = l[0::2]
	n = l[1::2]
	ans1 = all((k % 2 == 0 for k in m)) or all((k % 2 for k in m))
	ans2 = all((k % 2 == 0 for k in n)) or all((k % 2 for k in n))
	return ans1 and ans2
for _ in range(T):
	N = int(input())
	l = list(map(int, input().split()))
	print(['NO', 'YES'][solve(l)])


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	odd_f = nums[0] % 2
	even_f = nums[1] % 2
	result = True
	for i in range(0, n, 2):
		if nums[i] % 2 != odd_f:
			result = False
			break
	for i in range(1, n, 2):
		if nums[i] % 2 != even_f:
			result = False
			break
	if result:
		print('YES')
	else:
		print('NO')


from collections import defaultdict

def main():
	t = int(input())
	for _ in range(t):
		input()
		lst = list(map(int, input().split()))
		foo = True
		ans1 = lst[1] % 2 == 0
		for i in range(3, len(lst), 2):
			if ans1 != (lst[i] % 2 == 0):
				foo = False
		ans2 = lst[0] % 2 == 0
		for i in range(2, len(lst), 2):
			if ans2 != (lst[i] % 2 == 0):
				foo = False
		if foo:
			print('YES')
		else:
			print('NO')
main()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	ch = True
	a = l[0] % 2
	b = l[1] % 2
	while c < n:
		if l[c] % 2 != a:
			ch = False
			break
		c += 2
	c = 1
	while c < n:
		if l[c] % 2 != b:
			ch = False
			break
		c += 2
	if ch:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	num = input().split(' ')
	if n == 2:
		print('YES')
		continue
	first_odd = int(num[1])
	first_even = int(num[0])
	flag = 1
	for j in range(2, n):
		k = int(num[j])
		if j % 2 == 0:
			if k % 2 != first_even % 2:
				flag = 0
				break
		elif k % 2 != first_odd % 2:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())

def solve(li):
	A = li[::2]
	B = li[1::2]
	eoA = A[0] % 2
	eoB = B[0] % 2
	flagA = True
	flagB = True
	for a in A:
		if a % 2 != eoA:
			flagA = False
	for b in B:
		if b % 2 != eoB:
			flagB = False
	return (flagA, flagB)
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	(flagA, flagB) = solve(A)
	if flagA and flagB:
		print('YES')
	else:
		print('NO')


def sol(n, l):
	x = -1
	y = -1
	if l[0] % 2 == 0:
		x = 0
	else:
		x = 1
	if l[1] % 2 == 0:
		y = 0
	else:
		y = 1
	for i in range(2, n):
		if i % 2 == 0:
			if l[i] % 2 == x:
				pass
			else:
				return 'NO'
		elif l[i] % 2 == y:
			pass
		else:
			return 'NO'
	return 'YES'
t = int(input())
for ii in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	print(sol(n, l))


t = int(input())
while t:
	n = int(input())
	s = list(map(int, input().split()))
	flag = 0
	if n == 1:
		print('YES')
	else:
		k1 = s[0] & 1
		k2 = s[1] & 1
		for i in range(2, len(s), 2):
			if k1 != s[i] & 1:
				flag = 1
				break
		if flag == 0:
			for i in range(3, len(s), 2):
				if k2 != s[i] & 1:
					flag = 1
					break
		if flag == 1:
			print('NO')
		else:
			print('YES')
	t -= 1


from collections import defaultdict
t = int(input())

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	m = set()
	for i in a[::2]:
		m.add(i % 2)
	if len(m) > 1:
		print('NO')
		return
	m = set()
	for i in a[1::2]:
		m.add(i % 2)
	if len(m) > 1:
		print('NO')
		return
	print('YES')
for i in range(t):
	solve()


def inp(*, cf=lambda x: x):
	return cf(input())

def inpint():
	return inp(cf=int)

def inp_line(*, cf=lambda x: x, s=' '):
	return list(map(cf, input().split(s)))

def inpints():
	return inp_line(cf=int)

def test_case(case):
	n = inpint()
	a = inpints()
	if n <= 2:
		return 'YES'
	parity_odd = a[0] % 2
	parity_even = a[1] % 2
	for i in range(n):
		if i % 2 == 0:
			if parity_odd != a[i] % 2:
				return 'NO'
		if i % 2 == 1:
			if parity_even != a[i] % 2:
				return 'NO'
	return 'YES'

def main():
	T = inpint()
	for t in range(1, T + 1):
		print(test_case(t))
main()


for t in range(int(input())):
	a = int(input())
	c = False
	mylist = list(map(int, input().split()))
	(o1, o2) = (mylist[0] % 2, mylist[1] % 2)
	for i in range(a):
		if i % 2 == 0:
			if mylist[i] % 2 != o1:
				print('NO')
				c = True
				break
		elif mylist[i] % 2 != o2:
			print('NO')
			c = True
			break
	if not c:
		print('YES')


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	first = arr[0]
	flag1 = True
	if arr[0] % 2 == 0:
		first = 0
	else:
		first = 1
	for i in range(2, n, 2):
		if first == 0 and arr[i] % 2 == 0:
			pass
		elif first == 1 and arr[i] % 2 != 0:
			pass
		else:
			flag1 = False
	flag2 = True
	if arr[1] % 2 == 0:
		second = 0
	else:
		second = 1
	for i in range(3, n, 2):
		if second == 0 and arr[i] % 2 == 0:
			pass
		elif second == 1 and arr[i] % 2 != 0:
			pass
		else:
			flag2 = False
	if flag1 == True and flag2 == True:
		print('YES')
	else:
		print('NO')