Every day, Mike goes to his job by a bus, where he buys a ticket. On the ticket, there is a letter-code that can be represented as a string of upper-case Latin letters.
Mike believes that the day will be successful in case exactly two different letters in the code alternate.  Otherwise, he believes that the day will be unlucky. Please see note section for formal definition of alternating code.
You are given a ticket code. Please determine, whether the day will be successful for Mike or not. Print "YES" or "NO" (without quotes) corresponding to the situation.

-----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 and only line of each test case contains a single string S denoting the letter code on the ticket.

-----Output-----
For each test case, output a single line containing "YES" (without quotes) in case the day will be successful and "NO" otherwise.

-----Note-----
Two letters x, y where x != y are said to be alternating in a code, if code is of form "xyxyxy...".

-----Constraints-----

- 1 ≤ T ≤ 100
- S consists only of upper-case Latin letters

Subtask 1 (50 points):

- |S| = 2

Subtask 2 (50 points):

- 2 ≤ |S| ≤ 100

-----Example-----
Input:
2
ABABAB
ABC

Output:
YES
NO

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
for _ in range(int(input())):
	s = input()
	ls = set()
	for i in s:
		ls.add(i)
	if len(ls) != 2:
		print('NO')
	else:
		print('YES')


t = int(input())
for ni in range(t):
	s = input()
	s1 = set(s[::2])
	s2 = set(s[1::2])
	if s1 != s2 and len(s1) == len(s2) == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	l = []
	for i in s:
		l.append(i)
	if len(set(l)) == 2:
		print('YES')
	else:
		print('NO')


def res(s):
	if len(s) == 2:
		if s[0] == s[1]:
			print('NO')
		else:
			print('YES')
	else:
		c1 = s[0]
		c2 = s[1]
		counte = 0
		counto = 0
		for i in range(2, len(s)):
			if i % 2 == 0 and s[i] != c1:
				counte = 1
				break
			elif i % 2 != 0 and s[i] != c2:
				counto = 1
				break
		if counte != 0 or counto != 0:
			print('NO')
		else:
			print('YES')

def __starting_point():
	t = int(input())
	for _ in range(t):
		stri = str(input())
		res(stri)
__starting_point()


for i in range(int(input())):
	x = input()
	y = set(x)
	print('YES' if len(y) == 2 else 'NO')


for a in range(int(input())):
	S = str(input())
	l = []
	for letter in S:
		l.append(letter)
	if len(l) == 2:
		if l[0] == l[1]:
			print('NO')
		else:
			print('YES')
	else:
		num = 0
		while num < len(l) - 2:
			if len(l) == 3 and l[0] == l[2]:
				var = 0
				num += 1
			elif l[num] == l[num + 2] and l[num] != l[num + 1] and (len(l) != 3):
				var = 0
				num += 1
			else:
				var = 1
				break
		if var == 0:
			print('YES')
		else:
			print('NO')


def res(s):
	if len(s) == 2:
		if s[0] == s[1]:
			print('NO')
		else:
			print('YES')
	elif len(s) % 2 != 0:
		print('NO')
	else:
		counte = 0
		for i in range(2, len(s)):
			if i % 2 == 0:
				if s[i] != s[0]:
					counte = 1
					break
			elif s[i] != s[1]:
				counte = 1
				break
		if counte == 0:
			print('YES')
		else:
			print('NO')

def __starting_point():
	t = int(input())
	for _ in range(t):
		stri = str(input())
		res(stri)
__starting_point()


for i in range(int(input())):
	s_1 = input()
	a = set(s_1)
	if len(a) == 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	st = input()
	fl = False
	if st[0] != st[1]:
		fl = True
	for j in range(2, len(st)):
		if j % 2 == 0:
			if st[j] == st[0]:
				continue
			else:
				fl = False
		elif st[j] == st[1]:
			continue
		else:
			fl = False
	if fl == True:
		print('YES', end='\n')
	else:
		print('NO', end='\n')


for i in range(int(input())):
	string = input()
	if len(set(string)) == 2:
		print('YES')
	else:
		print('NO')


t = int(input(''))
if 1 <= t <= 100:
	for _ in range(t):
		s = input('')
		a = s[0]
		b = s[1]
		flag = 0
		if s.isupper() and 2 <= len(s) <= 100:
			if a != b:
				for i in range(len(s)):
					if i % 2 == 0 and s[i] == a:
						continue
					elif i % 2 == 1 and s[i] == b:
						continue
					else:
						flag = 1
						break
				if flag == 0:
					print('YES')
				else:
					print('NO')
			else:
				print('NO')


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	l = []
	for x in s:
		if x not in l:
			l.append(x)
	if len(l) == 2:
		for i in range(n - 1):
			if s[i] == s[i + 1]:
				print('NO')
				break
		else:
			print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	x = len(set(s))
	if x == 2:
		for j in range(len(s) - 1):
			if s[j] == s[j + 1]:
				print('N0')
				break
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	if len(set(s)) == 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	l = set(s)
	if len(l) == 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	n = len(s)
	k = s[:2]
	if len(set(k)) != 2:
		print('NO')
	else:
		p = n // 2
		if n % 2 == 0:
			if s == k * p:
				print('YES')
			else:
				print('NO')
		elif s == k * p + s[0]:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	n = len(s)
	i = 2
	if s[0] == s[1]:
		print('NO')
	else:
		for i in range(2, n):
			if s[i] != s[i - 2]:
				print('NO')
				break
		else:
			print('YES')


try:
	for _ in range(int(input())):
		s = input()
		s = list(s)
		p = set(s)
		cout = 0
		if len(p) == 2:
			for i in range(0, len(s) - 1):
				if s[i] == s[i + 1]:
					cout = 1
		else:
			cout = 1
		if cout == 1:
			print('NO')
		else:
			print('YES')
except:
	pass


t = int(input())
for _ in range(t):
	x = input()
	y = []
	for i in x:
		if i not in y:
			y.append(i)
	if len(y) != 2:
		print('NO')
	else:
		i = 0
		while i < len(x) - 1:
			if x[i] == x[i + 1]:
				print('NO')
				break
			i = i + 1
		else:
			print('YES')


t = int(input())
while t:
	t = t - 1
	s = set(input())
	if len(s) == 2:
		print('YES')
	else:
		print('NO')


i = int(input())
listk = []
for _ in range(i):
	st = input()
	st = st.upper()
	o = 0
	t = 'YES'
	while o < len(st):
		if len(st) % 2 == 1:
			st = st + st[1]
		if st[0] == st[1]:
			t = 'NO'
			break
		if st[0] != st[o] or st[1] != st[o + 1]:
			t = 'NO'
			break
		o = o + 2
	listk.append(t)
for ele in listk:
	print(ele)


for t in range(int(input())):
	string = input()
	n = len(string)
	if n == 1:
		print('NO')
	elif n == 2:
		if string[0] != string[1]:
			print('YES')
		else:
			print('NO')
	elif n > 2:
		first = string[0]
		second = string[1]
		if first == second:
			print('NO')
		else:
			flag = 1
			for i in range(2, n):
				if i % 2 != 0:
					if string[i] == second:
						flag = 1
					else:
						flag = 0
						break
				elif string[i] == first:
					flag = 1
				else:
					flag = 0
					break
		if flag == 1 and n == 3:
			print('NO')
		elif flag == 1:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	s = list(input())
	b = set(s)
	if len(b) == 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	word = input()
	list_w = list(word)
	set_w = list(set(list_w))
	if len(set_w) != 2:
		print('NO')
	else:
		s1 = ''
		s2 = ''
		for a in range(len(word)):
			if a % 2 == 0:
				s1 += word[a]
			else:
				s2 += word[a]
		if len(set(list(s1))) == 1 and len(set(list(s2))) == 1:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	(s, l) = (input(), [])
	for j in range(len(s)):
		if s[j] not in l:
			l.append(s[j])
	if len(l) == 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = input()
	b = []
	for i in a:
		if i not in b:
			b.append(i)
	if len(b) != 2:
		print('NO')
	else:
		i = 0
		while i < len(a) - 1:
			if a[i] == a[i + 1]:
				print('NO')
				break
			i = i + 1
		else:
			print('YES')


T = int(input())
for i in range(T):
	S = input()
	a = {}
	for ele in S:
		if ele not in a:
			a[ele] = 1
		else:
			a[ele] = a[ele] + 1
	c = 0
	for key in a:
		c = c + 1
	if c == 2:
		print('YES')
	else:
		print('NO')


a = int(input(''))
for i in range(a):
	t = input('')
	k = list(t)
	l = []
	c = 0
	for j in range(0, len(k) - 1):
		if k[j] != k[j + 1]:
			c = c + 1
	if c == len(k) - 1 and len(set(k)) == 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	S = input()
	good = True
	if S[0] != S[1]:
		for i in range(2, len(S), 2):
			if S[i] != S[0]:
				good = False
				break
		for i in range(3, len(S), 2):
			if S[i] != S[1]:
				good = False
				break
		if good:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = input()
for c in range(0, int(t)):
	s = input()
	ok = True
	for i in range(len(s) - 2):
		if s[i] != s[i + 2]:
			ok = False
			break
	if s[0] == s[1]:
		ok = False
	if ok:
		print('YES')
	else:
		print('NO')


T = int(input())
for _ in range(T):
	S = input()
	alternate = True
	dist = set(S)
	for s in range(1, len(S)):
		if S[s - 1] == S[s]:
			alternate = False
			break
	if alternate and len(dist) == 2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	b = input()
	a = set(b)
	if len(a) == 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	if len(set(s)) == 2:
		flag = True
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				flage = False
				break
		if flag == False:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	l1 = l / 2
	if l % 2 == 0:
		s1 = ''
		a = s[0]
		b = s[1]
		if a != b:
			s1 += a + b
			if s.count(s1) == l1:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	l = []
	for j in range(len(s)):
		if s[j] not in l:
			l.append(s[j])
	if len(l) == 2:
		print('YES')
	else:
		print('NO')


test = int(input())
for i in range(test):
	s = input()
	if len(set(s)) == 2:
		print('YES')
	else:
		print('NO')


def Solve(s):
	if len(set(s)) != 2:
		return 'NO'
	for i in range(len(s)):
		if i + 2 < len(s):
			if s[i] == s[i + 2]:
				continue
			else:
				return 'NO'
	return 'YES'
for _ in range(int(input())):
	s = input()
	print(Solve(s))


for t in range(int(input())):
	s = input()
	a = s[0]
	b = s[1]
	f = 1
	if a == b:
		f = 0
	else:
		c = a
		for i in s:
			if i != c:
				f = 0
				break
			if c == a:
				c = b
			else:
				c = a
	if f == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	if len(s) == 2:
		if s[0] != s[1]:
			print('YES')
		else:
			print('NO')
	else:
		flag = 1
		for i in range(len(s) - 2):
			if s[i] == s[i + 2] and s[i] != s[i + 1]:
				continue
			else:
				flag = -1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	x = input()
	a = len(x)
	if a == 1:
		print('NO')
	elif a == 2:
		if x[0] == x[1]:
			print('NO')
		else:
			print('YES')
	elif x[0] == x[1]:
		print('NO')
	else:
		for j in range(a - 2):
			if x[j] == x[j + 2]:
				if j == a - 3:
					print('YES')
					break
				else:
					pass
			else:
				print('NO')
				break


for _ in range(int(input())):
	s = input()
	flag = True
	if s[0] == s[1]:
		flag = False
	else:
		for i in range(len(s) - 2):
			if s[i] != s[i + 2]:
				flag = False
	print('YES') if flag else print('NO')


for i in range(int(input())):
	s = input()
	o = []
	e = []
	for i in range(len(s)):
		if i % 2 == 0:
			e.append(s[i])
		else:
			o.append(s[i])
	if o.count(o[-1]) == len(o) and e.count(e[-1]) == len(e):
		if o[-1] != e[-1]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for r in range(t):
	s = input()
	a = set()
	for i in range(len(s)):
		a.add(s[i])
	if len(a) == 2:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	s = input()
	l = len(s)
	f = 0
	if l == 2 and s[0] == s[1]:
		f = 1
	for j in range(1, l - 1):
		if s[j] == s[j + 1] or s[j - 1] != s[j + 1]:
			f = 1
			break
	if f == 0:
		print('YES')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	string = input()
	s = ''
	for i in string:
		if i in s:
			continue
		else:
			s += i
	if len(s) != 2:
		print('NO')
	else:
		print('YES')


T = int(input())
for _ in range(T):
	L = list(input())
	if len(set(L)) == 2:
		if len(L) == 2:
			print('YES')
		else:
			found = False
			for i in range(len(L) - 2):
				if L[i] == L[i + 2]:
					pass
				else:
					found = True
					break
			if found:
				print('NO')
			else:
				print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	c = 0
	l = []
	for i in s:
		if i not in l:
			l.append(i)
	if len(l) != 2:
		print('NO')
	else:
		for i in range(len(s) - 1):
			if s[i] == s[i + 1]:
				print('NO')
				c = 1
				break
		if c == 0:
			print('YES')


def solve(s):
	n = len(s)
	a = s[0]
	b = s[1]
	if a == b:
		return 'NO'
	for i in range(2, n):
		if i % 2 == 0 and s[i] != a:
			return 'NO'
		if i % 2 != 0 and s[i] != b:
			return 'NO'
	return 'YES'
for _ in range(int(input())):
	s = input()
	print(solve(s))


n = int(input())
for i in range(n):
	a = input()
	k = 1
	test = 1
	first = a[0]
	second = a[1]
	if first != second:
		for i in range(len(a)):
			if k:
				if a[i] != first:
					test = 0
					break
				k = 0
			else:
				if a[i] != second:
					test = 0
					break
				k = 1
		if test == 0:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = input()
	e = l[0]
	o = l[1]
	flag = True
	if l.isupper():
		if e != o:
			for i in range(len(l)):
				if i % 2 == 0 and l[i] != e:
					flag = False
					break
				elif i % 2 != 0 and l[i] != o:
					flag = False
					break
			if flag:
				print('YES')
			else:
				print('NO')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	i = 0
	n = len(s)
	if n == 2:
		if s[0] != s[1]:
			print('YES')
		else:
			print('NO')
	else:
		d = {}
		for ele in s:
			d[ele] = 0
		i = 0
		flag = 0
		while i < n - 1:
			if s[i] == s[i + 1]:
				flag = 1
				break
			i += 2
		if len(d) == 2 and flag == 0:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	s = input()
	a = s[0]
	b = s[1]
	c = 0
	d = 0
	if a != b:
		for i in range(len(s)):
			if i % 2 == 0 and s[i] == a:
				c += 1
			elif i % 2 == 1 and s[i] == b:
				d += 1
		if c + d == len(s):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	a = str(input())
	if len(set(a)) == 2:
		print('YES')
	else:
		print('NO')


r = int(input())
while r:
	r -= 1
	s = input()
	if len(s) == 2:
		if s[0] == s[1]:
			print('NO')
		else:
			print('YES')
	else:
		c = True
		for i in range(len(s) - 2):
			if s[i] == s[i + 2] and s[i] != s[i + 1]:
				continue
			else:
				c = False
				break
		if c:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	even = s[0]
	odd = s[1]
	flag = 1
	if even == odd:
		flag = 0
	for i in range(2, len(s)):
		if i % 2 == 0:
			if s[i] != even:
				flag = 0
				break
		elif s[i] != odd:
			flag = 0
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


for tc in range(int(input())):
	s = input()
	ans = 'YES'
	if s[1] == s[0]:
		ans = 'NO'
	else:
		for i in range(len(s)):
			if i % 2 == 0:
				if s[i] != s[0]:
					ans = 'NO'
			elif s[i] != s[1]:
				ans = 'NO'
	print(ans)


t = int(input())
while t:
	s = input()
	l1 = s[0]
	l2 = s[1]
	if l1 != l2:
		pos = True
		for i in range(2, len(s)):
			if i % 2 == 0 and l1 != s[i]:
				pos = False
				break
			elif i % 2 != 0 and l2 != s[i]:
				pos = False
				break
		if pos:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t -= 1


t = int(input())
while t:
	x = input()
	a = len(x)
	if a == 1:
		print('NO')
	elif a == 2:
		if x[0] == x[1]:
			print('NO')
		else:
			print('YES')
	elif x[0] == x[1]:
		print('NO')
	else:
		for j in range(a - 2):
			if x[j] == x[j + 2]:
				if j == a - 3:
					print('YES')
					break
			else:
				print('NO')
				break
	t -= 1


for _ in range(int(input())):
	s = input().strip()
	if len(set(s)) != 2:
		print('NO')
		continue
	(a, b) = set(s)
	c = 0
	n = len(s)
	for i in range(n):
		if i % 2 == 0 and s[i] == a:
			c += 1
		elif i % 2 == 1 and s[i] == b:
			c += 1
	if min(c, n - c) == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	letters = {}
	s = input()
	for x in s:
		if letters.get(x):
			letters[x] += 1
		else:
			letters[x] = 1
	if len(letters.keys()) != 2:
		print('NO')
	else:
		flag = False
		for i in range(2, len(s), 2):
			if s[i] != s[0]:
				flag = True
				break
		if flag:
			print('NO')
		else:
			print('YES')
	t -= 1


tests = int(input())
for i in range(tests):
	string = input()
	length = len(string)
	unique_set = set(string)
	if len(unique_set) != 2:
		print('NO')
	else:
		ans = 'YES'
		for j in range(1, length):
			if string[j] == string[j - 1]:
				ans = 'NO'
				break
		print(ans)


newlist = [[x for x in input('')] for _ in range(int(input('')))]
for items in newlist:
	if len(set(items)) == 2:
		print('YES')
	else:
		print('NO')