Read problems statements in Mandarin Chinese, Russian and Vietnamese as well. 

Limak is a little polar bear, who loves eating cookies and drinking milk.
For this reason he often visits Chef's kitchen.

Limak is going to spend N minutes in the kitchen.
Each minute he either eats a cookie or drinks milk.
Cookies are very sweet and thus Limak's parents have instructed him, that after eating a cookie, he has to drink milk in the next minute.

You are given whether he ate a cookie or drank milk in each of the N minutes. Your task is to check if Limak followed his parents' instructions. That is, you need to verify whether after each eaten cookie he drinks milk in the next minute.
Print "YES" or "NO" for each test case accordingly.

------ Input ------ 

The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

The first line of each test case contains an integer N denoting the number of minutes.

The second line of a test case contains N space-separated strings S_{1}, S_{2}, ..., S_{N}.
The string S_{i} is either "cookie" (if Limak eats a cookie in the i-th minute) or "milk" (otherwise).

------ Output ------ 

For each test case, output a single line containing the answer — "YES" if Limak followed his parents' instructions, and "NO" otherwise, both without the quotes.

------ Constraints ------ 

$1 ≤ T ≤ 50$
$1 ≤ N ≤ 50$
$ Each S_{i} is either "cookie" or "milk" (without the quotes).

------ Subtasks ------ 

$Subtask #1 (40 points) N = 2$
$Subtask #2 (60 points) Original constraints$

----- Sample Input 1 ------ 
4

7

cookie milk milk cookie milk cookie milk

5

cookie cookie milk milk milk

4

milk milk milk milk

1

cookie
----- Sample Output 1 ------ 
YES

NO

YES

NO
----- explanation 1 ------ 
Test case 1. Limak is in the kitchen for 7 minutes.
He eats three cookies and after each of them he indeed drinks milk in the next minute.
The answer is "YES".

Test case 2. Limak is in the kitchen for 5 minutes.
In the first minute he eats a cookie and in the second minute he eats a cookie again, instead of drinking milk.
The answer is "NO".

Test case 3. Here Limak doesn't eat any cookies.
The answer is "YES" because the condition is satisfied (there is no situation when Limak eats a cookie but doesn't drink milk in the next minute).

Test case 4. Limak eats a cookie and doesn't drink milk in the next minute so the answer is "NO".

Difficulty: EASY

Solutions:
t = int(input())
while t > 0:
	a = int(input())
	l = list(input().split())
	k = 0
	if l[-1] == 'cookie':
		print('NO')
	elif len(l) == 1 and l[0] == 'milk':
		print('YES')
	else:
		for i in range(a - 1):
			if l[i] == 'cookie' and l[i + 1] != 'milk':
				k += 1
				break
		if k == 1:
			print('NO')
		else:
			print('YES')
	t -= 1


for i in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	if l[-1] == 'cookie':
		print('NO')
	else:
		for i in range(n - 1):
			if l[i] == 'cookie':
				if l[i + 1] != 'milk':
					print('NO')
					break
				else:
					continue
		else:
			print('YES')


for _ in range(0, int(input())):
	x = int(input())
	l = list(map(str, input().split()))
	c = 0
	for i in range(0, len(l) - 1):
		if l[i] == 'cookie' and l[i + 1] == 'cookie':
			c = 1
	if l[-1] == 'cookie':
		c = 3
	if len(l) == 1:
		if l[0] == 'cookie':
			c = 2
	if c == 1 or c == 2 or c == 3:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	li = list(map(str, input().split()))
	s = 'YES'
	for i in range(len(li) - 1):
		if li[i] == 'cookie' and li[i + 1] == 'cookie':
			s = 'NO'
	if li[-1] == 'cookie':
		s = 'NO'
	print(s)


for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	p = 0
	o = 0
	for i in range(n):
		if p == 1:
			if l[i] != 'milk':
				o = 1
				break
			else:
				p = 0
		elif l[i] == 'cookie':
			p = 1
	if p == 1 or o == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	list_a = input().split()
	s = 'YES'
	for i in range(n - 1):
		if list_a[i] == 'cookie' and list_a[i + 1] == 'cookie':
			s = 'NO'
	if list_a[-1] == 'cookie':
		s = 'NO'
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	ls = list(map(str, input().split()))
	f = 0
	if n == 1:
		if ls[0] == 'cookie':
			f = 1
			print('NO')
		else:
			f = 1
			print('YES')
	for j in range(n - 1):
		if ls[j] == 'cookie' and ls[j + 1] == 'cookie':
			f = 1
			print('NO')
			break
	if f == 0 and ls[-1] == 'milk':
		print('YES')
	elif f == 0 and ls[-1] != 'milk':
		print('NO')


for i in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	s = 'YES'
	for i in range(n - 1):
		if l[i] == 'cookie' and l[i + 1] == 'cookie':
			s = 'NO'
	if l[-1] == 'cookie':
		s = 'NO'
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	eat = input().split(' ')
	if eat[-1] == 'cookie':
		print('NO')
	elif n > 1:
		for j in range(n - 1):
			if eat[j] == 'cookie' and eat[j + 1] == 'cookie':
				print('NO')
				break
		else:
			print('YES')
	elif eat[0] == 'cookie':
		print('NO')
	else:
		print('YES')


for j in range(int(input())):
	n = int(input())
	arr = list(map(str, input().split()))
	flag = True
	for i in range(n):
		if arr[i] == 'cookie':
			if i + 1 >= n or arr[i + 1] != 'milk':
				flag = False
	print('YES' if flag else 'NO')


q = int(input())
while q > 0:
	n = int(input())
	l = list(map(str, input().split()))
	flag = 0
	if l[n - 1] == 'cookie':
		flag = 1
	for i in range(n - 1):
		if l[i] == 'cookie':
			if l[i + 1] != 'milk':
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')
	q = q - 1


t = int(input())
for tc in range(t):
	n = int(input())
	l = list(map(str, input().split()))
	y = 'YES'
	for j in range(0, n):
		if l[n - 1] == 'cookie':
			y = 'NO'
		elif l[j] == 'cookie' and l[j - 1] == 'cookie':
			y = 'NO'
	print(y)


def bear(n, a):
	if n < 2 and a == ['cookie']:
		return 'NO'
	elif n < 2:
		return 'YES'
	for i in range(n - 1):
		if a[i] == 'cookie' and a[i + 1] != 'milk':
			return 'NO'
	if a[-1] == 'cookie':
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	a = input().split()
	print(bear(n, a))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(input().split())
	ans = 0
	if n == 1:
		if a[0] == 'cookie':
			print('NO')
			continue
	for i in range(n - 1):
		if a[i] == 'cookie' and a[i + 1] != 'milk':
			ans = 1
			break
	if a[n - 1] == 'cookie':
		ans = 1
	if ans == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input().split())
	fl = 0
	if n == 1:
		if s[0] == 'cookie':
			print('NO')
			continue
	for i in range(n - 1):
		if s[i] == 'cookie' and s[i + 1] != 'milk':
			fl = 1
			break
	if s[n - 1] == 'cookie':
		fl = 1
	if fl == 1:
		print('NO')
	else:
		print('YES')


def bear(n, a):
	f = True
	for i in range(n - 1):
		if a[i] == 'cookie' and a[i + 1] != 'milk':
			f = False
			break
	if f and a[n - 1] == 'cookie':
		f = False
	if f:
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	n = int(input())
	a = input().split()
	print(bear(n, a))


for i in range(int(input())):
	n = int(input())
	s = input().split()
	ans = 'YES'
	for i in range(n - 1):
		if s[i] == 'cookie' and s[i + 1] == 'cookie':
			ans = 'NO'
	if s[-1] == 'cookie':
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = input().split()
	ans = 'YES'
	for i in range(n - 1):
		if a[i] == 'cookie' and a[i + 1] == 'cookie':
			ans = 'NO'
			break
	if a[-1] == 'cookie':
		ans = 'NO'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	i = 0
	if l[-1] == 'cookie':
		print('NO')
	else:
		for x in range(n - 1):
			if l[x] == 'cookie' and l[x + 1] == 'cookie':
				i = 1
				print('NO')
				break
		if i == 0:
			print('YES')


def main():
	for _ in range(int(input())):
		n = int(input())
		A = list(map(str, input().split(' ')))[:n]
		flag = True
		for i in range(1, n):
			if A[i - 1] == 'cookie' and A[i] != 'milk':
				flag = False
				break
		if n == 1 and A[0] == 'cookie':
			flag = False
		elif A[-1] == 'cookie':
			flag = False
		print('YES' if flag else 'NO')
main()


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input().split()
	flag = True
	if s1[-1] == 'cookie':
		print('NO')
	else:
		for i in range(n - 1):
			if s1[i] == 'cookie':
				if s1[i + 1] == 'cookie':
					print('NO')
					flag = False
					break
		if flag == True:
			print('YES')


try:
	for _ in range(int(input())):
		N = int(input())
		S = list(map(str, input().split()))
		d = 0
		for i in range(N - 1):
			if S[i] == 'cookie' and S[i + 1] != 'milk':
				d = d + 1
		if N == 1 and S[0] == 'cookie':
			print('NO')
		elif S[-1] == 'cookie':
			print('NO')
		elif d != 0:
			print('NO')
		else:
			print('YES')
except:
	pass


for _ in range(int(input())):
	x = int(input())
	y = input().split()
	flag = True
	if y[-1] == 'cookie':
		print('NO')
	else:
		for i in range(len(y) - 1):
			if y[i] == 'cookie':
				if y[i + 1] == 'cookie':
					print('NO')
					flag = False
					break
				else:
					pass
			else:
				pass
		if flag:
			print('YES')


k = int(input())
for l in range(k):
	p = int(input())
	b = list(map(str, input().split()))
	if p == 1 and b[0] == 'cookie':
		print('NO')
	elif b[-1] == 'cookie':
		print('NO')
	else:
		l = 0
		f = 0
		while l < p - 1:
			if b[l] == 'cookie' and b[l + 1] == 'cookie':
				f = 1
				break
			l = l + 1
		if f == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	s = [j for j in input().split()]
	for j in range(n - 1):
		if s[j] == 'cookie' and s[j + 1] != 'milk':
			print('NO')
			break
	else:
		if s[n - 1] == 'cookie':
			print('NO')
		else:
			print('YES')


t = int(input())
for j in range(t):
	n = int(input())
	s = list(input().split())
	notmilk = 0
	if n == 1:
		if s[0] == 'cookie':
			print('NO')
		else:
			print('YES')
	else:
		for i in range(n - 1):
			if s[i] == 'cookie':
				if s[i + 1] != 'milk':
					notmilk += 1
		if notmilk >= 1 or s[-1] == 'cookie':
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	x = int(input())
	l = list(map(str, input().split()))
	flag = 0
	if x != 1:
		for i in range(x - 1):
			if l[i] == 'cookie' and l[i + 1] != 'milk':
				flag = 1
			if l[-1] == 'cookie':
				flag = 1
	elif l[0] == 'cookie':
		flag = 1
	if not flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	ans = True
	lis = list(map(str, input().split()))
	if n == 1 and lis[0] == 'cookie':
		print('NO')
		ans = False
	else:
		for i in range(n):
			if i == n - 1 and lis[i] == 'cookie':
				print('NO')
				ans = False
			elif lis[i] == 'cookie' and i != n - 1 and (lis[i + 1] == 'cookie'):
				print('NO')
				ans = False
				break
		if ans == True:
			print('YES')


t = int(input())
while t:
	N = int(input())
	S = list(input().split())
	f = 0
	for j in range(N):
		if j + 1 < N and S[j] == 'cookie' and (S[j + 1] != 'milk'):
			f = 1
			break
		elif S[N - 1] == 'cookie':
			f = 1
			break
	if f == 1:
		print('NO')
	else:
		print('YES')
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(str, input().split()))
	if n == 1 and arr[0] == 'cookie':
		print('NO')
	elif arr[-1] == 'cookie':
		print('NO')
	else:
		i = 0
		flag = 0
		while i < n - 1:
			if arr[i] == 'cookie' and arr[i + 1] == 'cookie':
				flag = 1
				break
			i = i + 1
		if flag == 1:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	s = list(map(str, input().split()))
	ans = 'YES'
	if s[-1] == 'cookie':
		ans = 'NO'
	else:
		for i in range(len(s) - 1):
			if s[i] == 'cookie' and s[i + 1] != 'milk':
				ans = 'NO'
				break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(str, input().split()))
	c = 'YES'
	if a[-1] == 'cookie':
		c = 'NO'
	else:
		for i in range(len(a) - 1):
			if a[i] == 'cookie' and a[i + 1] != 'milk':
				c = 'NO'
				break
	print(c)


for _ in range(int(input())):
	n = int(input())
	arr = input().split()
	for i in range(len(arr)):
		if i == len(arr) - 1 and arr[i] == 'cookie':
			print('NO')
			break
		elif arr[i] == 'cookie' and arr[i + 1] == 'cookie':
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for ni in range(t):
	n = int(input())
	l = input()
	cc = l.count('cookie')
	cm = l.count('milk')
	if 'cookie cookie' in l or cm < cc or l[-1] == 'e':
		print('NO')
	else:
		print('YES')


t = int(input(''))
for i in range(t):
	n = int(input())
	flag = 0
	l = list(map(str, input('').split()))
	if len(l) == 1:
		if l[0] == 'cookie':
			flag = 1
	if len(l) > 1:
		for k in range(len(l) - 1):
			if l[k] == 'cookie' and l[k + 1] == 'cookie':
				flag = 1
				break
			if l[len(l) - 1] == 'cookie':
				flag = 1
				break
	if flag == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
while t != 0:
	n = int(input())
	l = list(input().split())
	if l[n - 1] == 'cookie':
		print('NO')
	else:
		f = 0
		for k in range(0, n - 1):
			if l[k] == 'cookie' and l[k + 1] == 'cookie':
				f = 1
				break
		if f == 0:
			print('YES')
		else:
			print('NO')
	t -= 1


def cookie(wrd):
	if wrd[-1] == '0':
		return 'NO'
	if '00' in wrd:
		return 'NO'
	return 'YES'
for t in range(int(input())):
	n = int(input())
	wrd = input().replace(' ', '').replace('cookie', '0').replace('milk', '1')
	print(cookie(wrd))


for _ in range(int(input())):
	n = int(input())
	l = input().split()
	flag = 0
	i = 0
	if n == 1:
		if l[0] == 'milk':
			print('YES')
		else:
			print('NO')
	elif l[-1] == 'cookie':
		print('NO')
	else:
		while i < n - 1:
			flag = 0
			if l[i] == 'cookie':
				if l[i + 1] == 'milk':
					flag = 1
					i += 2
				else:
					flag = 0
					break
			else:
				flag = 1
				i += 1
		if flag:
			print('YES')
		else:
			print('NO')


for t in range(int(input())):
	n = int(input())
	wrd = input().replace(' ', '').replace('cookie', '0').replace('milk', '1')
	print('NO' if wrd[-1] == '0' or '00' in wrd else 'YES')


def cock(s):
	if s[-1] == 'cookie':
		return 'NO'
	for _ in range(len(s) - 1):
		if s[_] == 'cookie' and s[_ + 1] == 'cookie':
			return 'NO'
	return 'YES'
for t in range(int(input())):
	input()
	s = list(map(str, input().split()))
	if len(s) == 1 and s[0] == 'cookie':
		print('NO')
	elif len(s) == 1 and s[0] == 'milk':
		print('YES')
	else:
		print(cock(s))


for i in range(int(input())):
	n = int(input())
	l = list(input().split())
	c = 0
	if n == 1:
		if l[0] == 'cookie':
			print('NO')
		else:
			print('YES')
	else:
		for i in range(len(l) - 1):
			if l[i] == 'cookie':
				if l[i + 1] != 'milk':
					c = 1
					break
		if l[len(l) - 1] == 'cookie':
			c = 1
		if c == 1:
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	l = list(input().split(' '))
	c = 0
	for i in range(n - 1):
		if l[i] == 'cookie' and l[i + 1] == 'milk':
			c += 1
		else:
			continue
	if c == l.count('cookie'):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	l = input().split()
	if l[n - 1] == 'cookie':
		print('NO')
	else:
		c = 0
		for j in range(n):
			if l[j] == 'cookie' and l[j + 1] != 'milk':
				c = 1
				print('NO')
				break
		if c == 0:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	sl = input().split()
	res = 'YES'
	if sl[-1] == 'cookie':
		res = 'NO'
	else:
		for i in range(len(sl) - 1):
			if sl[i] == 'cookie' and sl[i + 1] == 'cookie':
				res = 'NO'
				break
	print(res)


a = int(input(''))
for i in range(a):
	x = int(input(''))
	p = input('').split()
	a = list(p)
	c = 0
	for i in range(x - 1):
		if a[i] == 'cookie' and a[i + 1] == 'cookie':
			c += 1
	if c != 0:
		print('NO')
	elif a[-1] == 'cookie':
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	l = input().split()
	c = 0
	for i in range(n - 1):
		if l[i] == 'cookie':
			if l[i + 1] == 'milk':
				c += 1
	if c == l.count('cookie'):
		print('YES')
	else:
		print('NO')


a = int(input(''))
for i in range(a):
	x = int(input(''))
	p = input('').split()
	k = list(p)
	c = 0
	for i in range(0, len(k) - 1):
		if k[i] == 'cookie' and k[i + 1] == 'cookie':
			c = c + 1
	if c != 0:
		print('NO')
	elif x == 1 and k[0] == 'cookie':
		print('NO')
	elif x == 2 and k[0] == 'milk' and (k[1] == 'cookie'):
		print('NO')
	elif k[-1] == 'cookie':
		print('NO')
	else:
		print('YES')


try:
	for _ in range(int(input())):
		N = int(input())
		L = [1 if i == 'cookie' else 0 for i in input().split(' ')]
		for i in range(N):
			if L[i] == 1 and (i == N - 1 or L[i + 1] != 0):
				print('NO')
				break
		else:
			print('YES')
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input().split()
	valid = True
	for i in range(len(arr) - 1):
		if arr[i] == 'cookie' and arr[i + 1] != 'milk':
			valid = False
	if arr[-1] == 'cookie':
		valid = False
	if valid:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	l = list(map(str, input().split(' ')))
	f = True
	if l[-1] == 'cookie':
		f = False
	else:
		for i in range(n - 1):
			if l[i] == 'cookie' and l[i + 1] == 'cookie':
				f = False
				break
	if f:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = list(map(str, input().strip().split()))
	c = 0
	for i in range(n - 1):
		if s[i] == 'cookie' and s[i + 1] == 'milk':
			c = 1
		elif s[i] == 'milk' and s[i + 1] == 'milk':
			c = 1
		elif s[i] == 'milk' and s[i + 1] == 'cookie' and (s[n - 1] != 'cookie'):
			c = 1
		else:
			c = 0
			break
	if n == 1 and s[n - 1] == 'milk':
		c = 1
	if c == 1:
		print('YES')
	else:
		print('NO')


(t, i) = (int(input()), 1)
response = []
while i <= t:
	order = int(input())
	ate = list(input().split())
	for item in range(len(ate)):
		if ate[item] == 'milk':
			response.append('YES')
		elif ate[-1] != 'cookie':
			if ate[item] == 'cookie' and ate[item + 1] == 'milk':
				response.append('YES')
			else:
				response.append('NO')
		else:
			response.append('NO')
	if 'NO' not in response:
		print('YES')
	else:
		print('NO')
	response = []
	i += 1


for tc in range(int(input())):
	n = int(input())
	s = list(input().split())
	flag = 1
	for cm in s:
		if cm == 'cookie':
			if flag == 0:
				break
			flag = 0
		else:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = list(map(str, input().split()))
	if 'milk' not in l:
		print('NO')
	elif 'cookie' not in l:
		print('YES')
	else:
		l = ''.join(l)
		if 'cookiecookie' in l or l[-1] == 'e':
			print('NO')
		else:
			print('YES')


for _ in range(int(input())):
	n = int(input())
	s = list(input().split())
	s.append('x')
	c = 0
	for i in range(n):
		if s[i] == 'cookie' and s[i + 1] != 'milk':
			c = 1
			break
	print('YES' if c == 0 else 'NO')


a = int(input())
for i in range(a):
	n = int(input())
	s = list(input().split(' '))
	s.append('x')
	flag = 0
	for j in range(n):
		if s[j] == 'cookie' and s[j + 1] != 'milk':
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
eats = []
for i in range(n):
	input()
	eats.append(input().split())

def answer(eat):
	for i in range(len(eat)):
		if eat[i] == 'cookie':
			if i == len(eat) - 1:
				return 'NO'
			if eat[i + 1] == 'milk':
				continue
			if eat[i + 1] == 'cookie':
				return 'NO'
	return 'YES'
for i in eats:
	print(answer(i))