*Words that contain many consecutive consonants, like "schtschurowskia", are generally considered somewhat hard to pronounce.*

We say that a word is *hard to pronounce* if it contains 4 or more consonants in a row; otherwise it is *easy to pronounce*. For example, "apple" and "polish" are easy to pronounce, but "schtschurowskia" is hard to pronounce.

You are given a string S consisting of N lowercase Latin characters. Determine whether it is easy to pronounce or not based on the rule above — print YES if it is easy to pronounce and NO otherwise.

For the purposes of this problem, the vowels are the characters \{a, e, i, o, u\} and the consonants are the other 21 characters.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two lines of input.
- The first line of each test case contains a single integer N, the length of string S.
- The second line of each test case contains the string S.

------ Output Format ------ 

For each test case, output on a new line the answer — YES if S is easy to pronounce, and NO otherwise.

Each character of the output may be printed in either uppercase or lowercase. For example, the strings YES, yeS, yes, and YeS will all be treated as identical.

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

$1 ≤ T ≤ 100$
$1 ≤ N ≤ 100$
$S$ contains only lowercase Latin characters, i.e, the characters $\{a, b, c, \ldots, z\}$

----- Sample Input 1 ------ 
5
5
apple
15
schtschurowskia
6
polish
5
tryst
3
cry
----- Sample Output 1 ------ 
YES
NO
YES
NO
YES

----- explanation 1 ------ 
Test case $1$: "$\text{apple}$" doesn't have $4$ or move consecutive consonants, which makes it easy to pronounce.

Test case $2$: "$\text{\textcolor{red}{schtsch}urowskia}$" has $7$ consecutive consonants, which makes it hard to pronounce.

Test case $3$: $\text{polish}$ doesn't contain $4$ or more consecutive consonants, so it's easy to pronounce.

Test case $4$: $\text{\textcolor{red}{tryst}}$ contains $5$ consecutive consonants, making it hard to pronounce.

Test case $5$: $\text{cry}$ doesn't contain any vowels, but its length is less than $4$ so it's still easy to pronounce.

Source: codechef | Difficulty: EASY
Tags: String algorithms

Data structures


Solutions:
for _ in range(int(input())):
	n = int(input())
	s = input()
	if n <= 3:
		print('YES')
	else:
		for i in range(n - 3):
			string = s[i:i + 4]
			vow1 = 'a' in string or 'e' in string or 'i' in string
			vow2 = 'o' in string or 'u' in string
			if not vow1 and (not vow2):
				print('NO')
				break
		else:
			print('YES')


T = int(input())
for i in range(T):
	N = int(input())
	S = input()
	c = 0
	huruf = False
	vokal = ['a', 'i', 'u', 'e', 'o']
	for j in range(N):
		if S[j] not in vokal:
			c += 1
		else:
			c = 0
		if c >= 4:
			huruf = True
	if huruf == True:
		print('NO')
	else:
		print('YES')


T = input()
n = 0
for n in range(int(T)):
	no_of_letters = input()
	if 1 <= int(no_of_letters) <= 100:
		string_ip = input()
		string_list = [letter for letter in string_ip]
		if len(string_list) < 4:
			print('YES')
		else:
			sum = 0
			for character in string_list:
				if character not in {'a', 'e', 'i', 'o', 'u'}:
					sum += 1
					if sum >= 4:
						break
				else:
					sum = 0
			if sum >= 4:
				print('NO')
			else:
				print('YES')
		n += 1
	else:
		pass


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	c = 0
	vowel = {'a', 'e', 'i', 'o', 'u'}
	for i in range(n):
		if s[i] in vowel:
			c = 0
		else:
			c = c + 1
		if c == 4:
			break
	if c == 4:
		print('NO')
	else:
		print('YES')


t = int(input())
l = ['a', 'e', 'i', 'o', 'u']
for i in range(t):
	n = int(input())
	s = input()
	count = 0
	for i in s:
		if i not in l:
			count += 1
			if count == 4:
				break
		else:
			count = 0
	if count < 4:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	n = int(input())
	st = str(input())
	c = 0
	if len(st) < 4:
		print('YES')
	else:
		for i in range(0, len(st) - 3):
			if 'a' in st[i:i + 4] or 'e' in st[i:i + 4] or 'i' in st[i:i + 4] or ('o' in st[i:i + 4]) or ('u' in st[i:i + 4]):
				continue
			else:
				c = c + 1
		if c != 0:
			print('NO')
		else:
			print('YES')


for i in range(int(input())):
	n = int(input())
	s = input()
	c = 0
	for i in s:
		if i not in 'aeiou':
			c += 1
		else:
			c = 0
		if c == 4:
			print('NO')
			break
	else:
		print('YES')


for t in range(int(input())):
	n = int(input())
	st = input()
	c = 0
	vowels = ['a', 'e', 'i', 'o', 'u']
	for i in st:
		if i not in vowels:
			c += 1
		else:
			c = 0
		if c == 4:
			break
	if c >= 4:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	x = int(input())
	y = str(input())
	w = 'aeiou'
	count = 0
	for i in y:
		if i not in w:
			count += 1
			if count == 4:
				break
		else:
			count = 0
	if count > 3:
		print('NO')
	else:
		print('YES')


vovels = ['a', 'e', 'i', 'o', 'u']
test = int(input())
ans = []
while test:
	test = test - 1
	N = int(input())
	S = input()
	count = 0
	for i in S:
		if count >= 4:
			break
		if i in vovels:
			count = 0
		else:
			count = count + 1
	if count >= 4:
		ans.append('NO')
	else:
		ans.append('YES')
for i in ans:
	print(i)


for _ in range(int(input())):
	n = int(input())
	s = input()
	c = 0
	for i in range(n):
		if s[i] not in ['a', 'e', 'i', 'o', 'u']:
			c += 1
			if c == 4:
				print('NO')
				break
		else:
			c = 0
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	s = input()
	f = 0
	cc = 0
	for i in s:
		if i in 'aeiou':
			cc = 0
		else:
			cc += 1
			if cc >= 4:
				f = 1
				break
	if f == 1:
		print('NO')
	else:
		print('YES')


def iep(s):
	cc = 0
	for i in s:
		if i in 'aeiou':
			cc = 0
		else:
			cc += 1
			if cc >= 4:
				return 'NO'
	return 'YES'
t1 = int(input())
for _ in range(t1):
	n = int(input())
	s = input()
	print(iep(s))


def is_easy_to_pronounce(s):
	consecutive_constant = 0
	for i in s:
		if i in 'aeiou':
			consecutive_constant = 0
		else:
			consecutive_constant += 1
			if consecutive_constant >= 4:
				return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(is_easy_to_pronounce(s))


for _ in range(int(input())):
	n = int(input())
	s = input()
	for char in list('aeiou'):
		s = s.replace(char, ' ')
	substrs = s.split()
	for el in substrs:
		if len(el) > 3:
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	st = input()
	temp = 0
	flag = False
	vowels = ['a', 'e', 'i', 'o', 'u']
	for j in st:
		if j not in vowels:
			temp = temp + 1
		else:
			temp = 0
		if temp >= 4:
			flag = True
	if flag:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	a = int(input())
	w = input()
	c = 0
	flag = False
	for j in range(len(w)):
		if w[j] not in ['a', 'e', 'i', 'o', 'u']:
			c = c + 1
		else:
			c = 0
		if c >= 4:
			flag = True
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
v = ['a', 'e', 'i', 'o', 'u']
while t > 0:
	c = 1
	n = int(input())
	str = input()
	for i in range(n):
		if i == n - 1:
			break
		elif str[i] not in v and str[i + 1] not in v:
			c += 1
			if c >= 4:
				break
		else:
			c = 1
	if c >= 4:
		print('NO')
	else:
		print('YES')
	t -= 1


for _ in range(int(input())):
	n = int(input())
	m = input()
	if n <= 3:
		print('YES')
	else:
		for i in range(n - 3):
			t = m[i:i + 4]
			p = 'a' in t or 'e' in t or 'i' in t
			l = 'o' in t or 'u' in t
			if not p and (not l):
				print('NO')
				break
		else:
			print('YES')


n = int(input())
for i in range(n):
	length = int(input())
	word = input()
	for v in 'aeiou':
		word = word.replace(v, ' ')
	print('NO' if any(filter(lambda c: len(c) >= 4, word.split())) else 'YES')


for _ in range(int(input())):
	t = int(input())
	c = 0
	ls = []
	a = input()[:t]
	for i in a:
		if i not in ['a', 'e', 'i', 'o', 'u']:
			c += 1
		elif c:
			ls.append(c)
			c = 0
	else:
		ls.append(c)
	print('YES' if max(ls) < 4 else 'NO')


v = "['a','e','i','o','u']"
for _ in range(int(input())):
	N = int(input())
	s = input()
	c = 0
	flag = False
	for i in range(N):
		if s[i] not in v:
			c = c + 1
		else:
			c = 0
		if c >= 4:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')


T = int(input())
for i in range(T):
	count = 0
	n = 1
	N = int(input())
	S = input()
	for k in S:
		if k not in 'aeiou':
			count += 1
			if count >= 4:
				print('NO')
				break
		else:
			count = 0
		if n == N and count < 4:
			print('YES')
		n += 1


for _ in range(int(input())):
	(N, S) = (int(input()), input())
	if N < 4:
		print('YES')
		continue
	count = 0
	g = False
	for i in S:
		if i not in ['a', 'e', 'i', 'o', 'u']:
			count += 1
		else:
			count = 0
		if count >= 4:
			g = True
	if g:
		print('NO')
	else:
		print('YES')


for n in range(int(input())):
	v = ['a', 'e', 'i', 'o', 'u']
	c = 0
	flag = 0
	r = int(input())
	str = input()
	for i in str:
		if i not in v:
			c = c + 1
		else:
			c = 0
		if c >= 4:
			flag = 1
	if flag:
		print('NO')
	else:
		print('YES')


l = ['a', 'e', 'i', 'o', 'u']
n = int(input())
for i in range(n):
	size = int(input())
	s = input()
	c = k = 0
	while k < size:
		if s[k] not in l:
			c = c + 1
			k = k + 1
		else:
			c = 0
			k = k + 1
		if c >= 4:
			print('NO')
			break
	if k == len(s) and c < 4:
		print('YES')


t = int(input())
for i in range(t):
	vowels = ['a', 'e', 'i', 'o', 'u']
	n = int(input())
	s = input()
	concount = 0
	for j in range(n):
		if s[j] not in vowels:
			concount += 1
			if concount == 4:
				break
		else:
			concount = 0
	print('YES') if concount < 4 else print('NO')


vowels = {'a', 'e', 'i', 'o', 'u'}
for i in range(int(input())):
	n = int(input())
	s = input()
	count = flag = 0
	for j in range(n):
		if s[j] in vowels:
			count = 0
		else:
			count += 1
		if count == 4:
			print('NO')
			flag = 1
			break
	if flag == 0:
		print('YES')


t = int(input())
for i in range(t):
	x = int(input())
	y = input()
	vowels = ['a', 'e', 'i', 'o', 'u']
	count = 0
	for c in y:
		if c in vowels:
			count = 0
			continue
		else:
			count += 1
		if count == 4:
			print('NO')
			break
	if count < 4:
		print('YES')


for i in range(int(input())):
	n = int(input())
	l = list(input())
	(s, a) = (0, 0)
	v = ['a', 'e', 'i', 'o', 'u']
	for i in range(len(l)):
		if l[i] not in v:
			s += 1
		else:
			s = 0
		if s >= 4:
			a += 1
	if a > 0:
		print('NO')
	else:
		print('YES')


vowels = {'a', 'e', 'i', 'o', 'u'}

def pronounce(n, s):
	k = 0
	for i in range(n):
		if s[i] in vowels:
			k = 0
		else:
			k += 1
			if k == 4:
				return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(pronounce(n, s))


t = int(input())
for i in range(0, t):
	a = int(input())
	n = input()
	l = ['a', 'e', 'i', 'o', 'u']
	m = 0
	c = 0
	for i in n:
		if i not in l:
			c += 1
		else:
			c = 0
		if c > m:
			m = c
	if m >= 4:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	N = int(input())
	S = input()
	count = 0
	lst = ['a', 'e', 'i', 'o', 'u']
	for i in S:
		if i.lower() in lst:
			count = 0
		else:
			count += 1
		if count == 4:
			break
	if count >= 4:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	n = int(input())
	x = input()
	d = ['a', 'e', 'i', 'o', 'u']
	count = 0
	flag = 0
	for j in range(n):
		if x[j] not in d:
			count += 1
		else:
			count = 0
		if count == 4:
			flag = 1
			print('NO')
			break
	if flag == 0:
		print('YES')


n = int(input())
for i in range(n):
	N = int(input())
	S = str(input())
	count = 0
	l = ['a', 'e', 'i', 'o', 'u']
	for i in range(N):
		if S[i] not in l:
			count += 1
		else:
			count = 0
		if count >= 4:
			print('NO')
			break
	if count < 4:
		print('YES')


T = input()
vowels = ['a', 'e', 'i', 'o', 'u']
count = 0
for i in range(int(T)):
	count = 0
	N = input()
	S = input()
	for j in S:
		if not j in vowels:
			count += 1
		else:
			if count >= 4:
				break
			count = 0
	if count >= 4:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	cnt = 0
	vowels = ['a', 'e', 'i', 'o', 'u']
	statment = True
	if n < 4:
		print('YES')
	else:
		for i in s:
			if i not in vowels:
				cnt += 1
				if cnt >= 4:
					statment = False
					break
			else:
				cnt = 0
		if statment == True:
			print('YES')
		else:
			print('NO')


T = int(input())
while T > 0:
	n = int(input())
	s = input()
	count = 0
	for i in s:
		if i not in 'AEIOUaeiou':
			count = count + 1
		elif count < 4:
			count = 0
		elif count >= 4:
			continue
	if count >= 4:
		print('NO')
	else:
		print('YES')
	T = T - 1


vowels = set(['a', 'e', 'i', 'o', 'u'])

def is_easy_to_pronounce(s):
	consective_consonants = 0
	for c in s:
		if c in vowels:
			consective_consonants = 0
		else:
			consective_consonants += 1
			if consective_consonants >= 4:
				return 'NO'
	return 'YES'
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	result = is_easy_to_pronounce(s)
	print(result)


def is_consonant(c):
	return c not in ['a', 'e', 'i', 'o', 'u']

def is_easy_to_pronounce(s):
	count = 0
	for c in s:
		if is_consonant(c):
			count += 1
			if count >= 4:
				return 'NO'
		else:
			count = 0
	return 'YES'

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		print(is_easy_to_pronounce(s))
main()


def decide(s):
	res = 0
	vowels = ['a', 'e', 'i', 'o', 'u']
	for i in s:
		if i not in vowels:
			res += 1
		elif res >= 4:
			return res
		else:
			res = 0
	return res
n = int(input())
for i in range(n):
	x = int(input())
	s = input()
	if decide(s) >= 4:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	a = int(input())
	string = input()
	count = 0
	for i in range(a):
		if string[i] in ['a', 'e', 'i', 'o', 'u']:
			count = 0
		else:
			count += 1
		if count == 4:
			print('NO')
			break
	else:
		print('YES')


testCases = int(input())
for _ in range(testCases):
	wordLength = int(input())
	word = str(input())
	if wordLength <= 3:
		print('YES')
	else:
		consecutiveConsonants = 0
		vowels = 'aeiou'
		for char in word:
			if char not in vowels:
				consecutiveConsonants += 1
			else:
				consecutiveConsonants = 0
			if consecutiveConsonants == 4:
				break
		if consecutiveConsonants == 4:
			print('NO')
		else:
			print('YES')


t = int(input())
for i in range(t):
	l = int(input())
	ch = input()
	c = 0
	if l >= 4:
		for j in range(l):
			if ch[j] != 'a' and ch[j] != 'e' and (ch[j] != 'i') and (ch[j] != 'o') and (ch[j] != 'u'):
				c += 1
				if c >= 4:
					break
			else:
				c = 0
		if c >= 4:
			print('NO')
		else:
			print('YES')
	else:
		print('YES')