Casimir has a string $s$ which consists of capital Latin letters 'A', 'B', and 'C' only. Each turn he can choose to do one of the two following actions:

he can either erase exactly one letter 'A' and exactly one letter 'B' from arbitrary places of the string (these letters don't have to be adjacent);

or he can erase exactly one letter 'B' and exactly one letter 'C' from arbitrary places in the string (these letters don't have to be adjacent).

Therefore, each turn the length of the string is decreased exactly by $2$. All turns are independent so for each turn, Casimir can choose any of two possible actions.

For example, with $s$ $=$ "ABCABC" he can obtain a string $s$ $=$ "ACBC" in one turn (by erasing the first occurrence of 'B' and the second occurrence of 'A'). There are also many other options for a turn aside from this particular example.

For a given string $s$ determine whether there is a sequence of actions leading to an empty string. In other words, Casimir's goal is to erase all letters from the string. Is there a way to do this?


-----Input-----

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

Each test case is described by one string $s$, for which you need to determine if it can be fully erased by some sequence of turns. The string $s$ consists of capital letters 'A', 'B', 'C' and has a length from $1$ to $50$ letters, inclusive.


-----Output-----

Print $t$ lines, each line containing the answer to the corresponding test case. The answer to a test case should be YES if there is a way to fully erase the corresponding string and NO otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes, and YES will all be recognized as positive answers).


-----Examples-----

Input
6
ABACAB
ABBA
AC
ABC
CABCBB
BCBCBCBCBCBCBCBC
Output
NO
YES
NO
NO
YES
YES


-----Note-----

None

Difficulty: EASY

Solutions:
def solve(s):
	return s.count('B') == s.count('A') + s.count('C')
n = int(input())
for i in range(n):
	s = input()
	if solve(s):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	lst = [a + b + c]
	if len(set(s)) == 1:
		print('NO')
		continue
	if b == 0:
		print('NO')
		continue
	if b - a == c or b - c == a:
		print('YES')
	else:
		print('NO')


def solution():
	for t in range(int(input())):
		s = input()
		l = len(s)
		if s.count('B') * 2 == l:
			print('YES')
		else:
			print('NO')
	return
solution()


inp = int(input())
res = []
for i in range(0, inp):
	x = input()
	if x.count('A') + x.count('C') == x.count('B'):
		res.append('YES')
	else:
		res.append('NO')
[print(x) for x in res]


n = int(input())
for _ in range(n):
	s = input()
	ac = bc = cc = 0
	for ele in s:
		if ele == 'A':
			ac += 1
		elif ele == 'B':
			bc += 1
		else:
			cc += 1
	if bc == ac + cc:
		print('YES')
	else:
		print('NO')


def check(s):
	(a, b, c) = (0, 0, 0)
	for i in s:
		if i == 'A':
			a += 1
		elif i == 'B':
			b += 1
		elif i == 'C':
			c += 1
	if a + c == b:
		print('YES')
	else:
		print('NO')
for t in range(int(input())):
	s = input()
	check(s)


for i in range(int(input())):
	s = input()
	num_a = s.count('A')
	num_b = s.count('B')
	num_c = s.count('C')
	if num_a + num_c == num_b:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	x = 0
	y = 0
	z = 0
	for i in range(len(s)):
		if s[i] == 'A':
			x = x + 1
		if s[i] == 'B':
			y = y + 1
		if s[i] == 'C':
			z = z + 1
	if x + z == y:
		print('YES')
	else:
		print('NO')


loop = int(input())
for idx in range(loop):
	str = input().upper()
	A = str.count('A')
	B = str.count('B')
	C = str.count('C')
	if A + C == B:
		print('YES')
	else:
		print('NO')


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

def solve():
	s = input()
	c = Counter(s)
	c['B'] -= c['C']
	c['B'] -= c['A']
	if c['B'] == 0:
		print('YES')
	else:
		print('NO')
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	s = input()
	ca = s.count('A')
	cb = s.count('B')
	cc = s.count('C')
	if cb - ca - cc == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	stroka = list(input())
	D = {'A': 0, 'B': 0, 'C': 0}
	for c in stroka:
		D[c] += 1
	if D['A'] + D['C'] == D['B']:
		print('YES')
	else:
		print('NO')


from collections import Counter
import sys, io, os
input = sys.stdin.readline

def solve():
	T = int(input())
	for _ in range(T):
		S = input().strip()
		c = Counter(S)
		if c['B'] > 0 and c['B'] == c['A'] + c['C']:
			print('YES')
		else:
			print('NO')
solve()


n = int(input())
for i in range(n):
	a = input()
	q1 = 0
	q2 = 0
	q3 = 0
	for e in range(len(a)):
		if a[e] == 'A':
			q1 += 1
		elif a[e] == 'B':
			q2 += 1
		elif a[e] == 'C':
			q3 += 1
	if q1 + q3 == q2:
		print('YES')
	else:
		print('NO')


b = 0
t = int(input())
for i in range(t):
	l = input()
	if l.count('B') == len(l) / 2:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	l = list(input())
	a = l.count('A')
	b = l.count('B')
	c = l.count('C')
	if b == 0:
		print('NO')
	elif len(set(l)) == 3:
		if b == c + a:
			print('YES')
		else:
			print('NO')
	elif a == 0:
		if b == c:
			print('YES')
		else:
			print('NO')
	elif c == 0:
		if b == a:
			print('YES')
		else:
			print('NO')


from collections import Counter
for _ in range(int(input())):
	c = Counter(input())
	print('YES' if c['B'] - c['A'] == c['C'] else 'NO')


t = int(input())
for _ in range(t):
	s = input()
	ca = cb = cc = 0
	for i in s:
		if i == 'A':
			ca += 1
		elif i == 'B':
			cb += 1
		else:
			cc += 1
	if ca + cc == cb:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	count_a = s.count('A')
	count_b = s.count('B')
	count_c = s.count('C')
	if count_a + count_c == count_b:
		print('YES')
	else:
		print('NO')


n = int(input())
inputs = [input() for i in range(n)]
for i in inputs:
	if list(i).count('A') + list(i).count('C') == list(i).count('B'):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	S = input()
	Hm = {'A': 0, 'B': 0, 'C': 0}
	for i in S:
		Hm[i] += 1
	a = Hm['A']
	b = Hm['B']
	c = Hm['C']
	b -= a
	if b == c:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
x = 0
b = 0
c = 0
for i in range(n):
	a.append(input())
for i in range(len(a)):
	for j in range(len(a[i])):
		if a[i][j] == 'B':
			b += 1
		elif a[i][j] == 'C':
			c += 1
		elif a[i][j] == 'A':
			x += 1
	if x + c == b:
		print('YES')
	else:
		print('NO')
	x = 0
	b = 0
	c = 0


t = int(input())
for i in range(t):
	Soli = list(input())
	A = Soli.count('A')
	B = Soli.count('B')
	C = Soli.count('C')
	if A + C == B:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	str = input()
	a = str.count('A')
	b = str.count('B')
	c = str.count('C')
	if a + c == b:
		print('YES')
	else:
		print('NO')
	t = t - 1


def check(val):
	x = val.count('A')
	y = val.count('B')
	z = val.count('C')
	if x - y > 0:
		print('NO')
	elif z - y > 0:
		print('NO')
	elif x - y < 0 and z + (x - y) == 0:
		print('YES')
	elif z - y < 0 and x + (z - y) == 0:
		print('YES')
	elif x - y == 0 and z > 0:
		print('NO')
	elif z - y == 0 and x > 0:
		print('NO')
	elif x - y == 0 and z == 0 or (z - y == 0 and x == 0):
		print('YES')
	elif x + y != z:
		print('NO')
trials = int(input())
li = []
for i in range(0, trials):
	temp = input()
	li.append(temp)
for l in li:
	check(l)


numberTestCases = int(input())
cases = []
output = []
for i in range(numberTestCases):
	cases.append(input())
for case in cases:
	numA = case.count('A')
	numB = case.count('B')
	numC = case.count('C')
	if numA + numC == numB:
		output.append('YES')
	else:
		output.append('NO')
for out in output:
	print(out)


for _ in range(int(input())):
	l = [i for i in input()]
	if len(l) % 2 == 1:
		print('NO')
	elif l.count('B') == l.count('A') + l.count('C'):
		print('YES')
	else:
		print('NO')


def main(string):
	if len(set(string)) == 1:
		return 'NO'
	elif 'B' not in string:
		return 'NO'
	elif 'A' not in string:
		if string.count('B') == string.count('C'):
			return 'YES'
		return 'NO'
	elif 'C' not in string:
		if string.count('B') == string.count('A'):
			return 'YES'
		return 'NO'
	else:
		if string.count('B') == string.count('A') + string.count('C'):
			return 'YES'
		return 'NO'
for _ in range(int(input())):
	print(main(input()))


def func(n):
	for _ in range(n):
		a = input()
		if a.count('B') == len(a) / 2:
			k.append('YES')
		else:
			k.append('NO')
	print('\n'.join(k))
k = []
func(int(input()))


n = int(input())
for _ in range(n):
	s = input()
	i = 0
	(r, p) = (0, 0)
	for i in s:
		if i == 'A' or i == 'C':
			r += 1
		elif i == 'B':
			p += 1
	if r == p:
		print('YES')
	else:
		print('NO')


test_cases = input()
string_array = []
for i in range(int(test_cases)):
	string_array.append(input())
for string in string_array:
	sum_dict = {'A': 0, 'B': 0, 'C': 0}
	for i in string:
		sum_dict[i] += 1
	if sum_dict['A'] + sum_dict['C'] == sum_dict['B']:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = ''.join(sorted(input()))
	while 'AB' in s or 'BA' in s:
		s = s.replace('AB', '').replace('BA', '')
	while 'BC' in s or 'CB' in s:
		s = s.replace('BC', '').replace('CB', '')
	if len(s) == 0:
		print('YES')
	else:
		print('NO')


import sys

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

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

def get_list_string():
	return list(map(str, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

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

def get_print(x):
	sys.stdout.write(x + '\n')

def get_print_int_same(x):
	sys.stdout.write(str(x) + ' ')

def get_print_same(x):
	sys.stdout.write(x + ' ')
from sys import maxsize

def solve():
	for _ in range(get_int()):
		s = get_string()
		(a, b, c) = (0, 0, 0)
		for i in range(len(s)):
			if s[i] == 'A':
				a += 1
			elif s[i] == 'B':
				b += 1
			else:
				c += 1
		if a == 0:
			if b == 0 or c == 0:
				get_print('NO')
			elif b == c:
				get_print('YES')
			else:
				get_print('NO')
		elif b == 0:
			get_print('NO')
		elif c == 0:
			if b == 0 or a == 0:
				get_print('NO')
			elif b == a:
				get_print('YES')
			else:
				get_print('NO')
		elif b == a + c:
			get_print('YES')
		else:
			get_print('NO')
solve()


for _t in range(int(input())):
	s = input()
	if 2 * s.count('B') == len(s):
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	s = input()
	(countA, countB, countC) = (0, 0, 0)
	res = ''
	for i in s:
		if i == 'A':
			countA += 1
		elif i == 'B':
			countB += 1
		else:
			countC += 1
	if countB == countA + countC:
		res = 'YES'
	else:
		res = 'NO'
	print(res)
	t -= 1


t = int(input())
for i in range(t):
	s = input()
	d = {'A': 0, 'B': 0, 'C': 0}
	for i in s:
		d[i] += 1
	if d['B'] == d['A'] + d['C']:
		print('YES')
	else:
		print('NO')


import sys
from collections import Counter
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	s = Counter(input())
	if s['A'] + s['C'] == s['B']:
		print('YES')
	else:
		print('NO')


for t in range(int(input())):
	s = input()
	a = s.count('A')
	b = s.count('B')
	c = len(s) - a - b
	print('YES' if a + c == b else 'NO')


for _ in range(int(input())):
	s = input()
	n = len(s)
	c = 0
	b = 0
	a = 0
	if n < 2:
		print('NO')
	else:
		for i in range(n):
			if s[i] == 'A':
				a += 1
			elif s[i] == 'B':
				b += 1
			else:
				c += 1
		if a + c == b:
			print('YES')
		else:
			print('NO')


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07

def hnbhai(tc):
	s = sa()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if a + c == b:
		print('YES')
		return
	print('NO')
for _ in range(sb()):
	hnbhai(_ + 1)


for i in range(int(input())):
	ch = input()
	if 2 * ch.count('B') == len(ch):
		print('YES')
	else:
		print('NO')


import sys
readline = sys.stdin.readline
T = int(readline())
for _ in range(T):
	S = readline().rstrip()
	(A, B, C) = (0, 0, 0)
	for s in S:
		if s == 'A':
			A += 1
		elif s == 'B':
			B += 1
		else:
			C += 1
	if A + C == B:
		ans = 'YES'
	else:
		ans = 'NO'
	print(ans)


T = int(input())
for i in range(T):
	s = input()
	a = []
	a[:0] = s
	if a.count('A') + a.count('C') == a.count('B'):
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def get():
	return input().strip()
for _ in range(int(get())):
	l = list(get())
	a = len(l)
	c = 0
	while True:
		f = 0
		if 'A' in l and 'B' in l and (c < 2):
			l.remove('A')
			l.remove('B')
			f = 1
		if 'C' in l and 'B' in l and (c < 2):
			l.remove('C')
			l.remove('B')
			f = 1
		if f == 0:
			break
	if len(l) == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = input()
	ac = bc = cc = 0
	for i in a:
		if i == 'A':
			ac += 1
		elif i == 'B':
			bc += 1
		elif i == 'C':
			cc += 1
	if ac + cc == bc:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = 0
	b = 0
	c = 0
	inpt = input()
	for j in inpt:
		if j == 'A':
			a = a + 1
		elif j == 'B':
			b = b + 1
		else:
			c = c + 1
	if len(inpt) % 2 == 0 and len(inpt) / 2 == b:
		if a == b or c == b or a + c == b:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def prob1():
	t = int(input())
	for i in range(t):
		s = input('')
		nummap = {'A': 0, 'B': 0, 'C': 0}
		for j in range(len(s)):
			nummap[s[j]] += 1
		nummap['B'] = nummap['B'] - nummap['A'] - nummap['C']
		if nummap['B'] == 0:
			print('YES')
		else:
			print('NO')
prob1()


for i in range(int(input())):
	x = list(input())
	if x.count('B') == len(x) / 2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	count = s.count('B')
	remlen = len(s) - count * 2
	if remlen == 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for j in range(n):
	s = input()
	ca = 0
	cb = 0
	cc = 0
	for i in s:
		if i == 'A':
			ca += 1
		elif i == 'B':
			cb += 1
		else:
			cc += 1
	print('YES' if cb == ca + cc else 'NO')


t = int(input())
for i in range(t):
	s = str(input())
	A = 0
	B = 0
	C = 0
	if len(s) % 2 == 1:
		print('NO')
	else:
		for j in range(len(s)):
			if s[j] == 'B':
				B += 1
			elif s[j] == 'A':
				A += 1
			elif s[j] == 'C':
				C += 1
		if B == A + C:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	b = s.count('B')
	if len(s) - b == b:
		print('YES')
	else:
		print('NO')


def sol(s):
	d = {'A': 0, 'B': 0, 'C': 0}
	for si in s:
		d[si] += 1
	total = len(s)
	if d['A'] * 2 + d['C'] * 2 == total:
		if d['A'] + d['C'] == d['B']:
			return 'YES'
	return 'NO'
t = int(input())
ans = []
for i in range(t):
	temp = input()
	ans.append(sol(temp))
for i in ans:
	print(i)


n = int(input())
for i in range(n):
	s = [i for i in input()]
	while s.count('B') != 0 and s.count('C') != 0:
		s.remove('B')
		s.remove('C')
	while s.count('A') != 0 and s.count('B') != 0:
		s.remove('A')
		s.remove('B')
	if len(s) == 0:
		print('YES')
	else:
		print('NO')


for s in [*open(0)][1:]:
	print('YNEOS'[2 * s.count('B') != len(s) - 1::2])


def solve():
	string = input()
	(a, b, c) = (0, 0, 0)
	for i in string:
		if i == 'A':
			a += 1
		elif i == 'B':
			b += 1
		else:
			c += 1
	if a + c == b:
		return 'YES'
	return 'NO'
t = int(input())
while t != 0:
	res = solve()
	print(res)
	t -= 1


import os, sys, math
from io import BytesIO, IOBase
ip = lambda : input()
it = lambda : int(input())
ma = lambda : map(int, input().split(' '))
li = lambda : list(map(int, input().split(' ')))
mod = 10 ** 9 + 7
md = 998244353

def solve(a, n, x):
	return a

def main():
	for _ in range(int(input())):
		s = ip()
		l = len(s)
		a = s.count('A')
		b = s.count('B')
		c = l - a - b
		if b == a + c:
			print('YES')
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def test():
	t = int(input())
	for _ in range(t):
		d = [0, 0, 0]
		s = input()
		for c in s:
			if c == 'A':
				d[0] += 1
			elif c == 'B':
				d[1] += 1
			else:
				d[2] += 1
		if d[0] + d[2] == d[1]:
			print('YES')
		else:
			print('NO')
test()


n = int(input())
for i in range(n):
	a = input()
	c = 0
	if a == 'AB' or a == 'BC' or a == 'CB' or (a == 'BA'):
		print('YES')
	elif len(a) % 2 != 0 or len(a) <= 2:
		print('NO')
	else:
		for P in a:
			if P == 'B':
				c = c + 1
		if c == len(a) // 2:
			print('YES')
		else:
			print('NO')


num = int(input())
ar = []
for i in range(num):
	ar.append(input())
for i in range(num):
	if ar[i].count('B') == len(ar[i]) / 2:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	a = b = 0
	for i in s:
		if i == 'A' or i == 'C':
			a += 1
		else:
			b += 1
	print('YES' if a == b else 'NO')


t = int(input())
while t > 0:
	s = input()
	cnt1 = 0
	cnt2 = 0
	cnt3 = 0
	for i in range(0, len(s)):
		if s[i] == 'B':
			cnt1 += 1
	if len(s) == 2 * cnt1:
		print('YES')
	else:
		print('NO')
	t -= 1


hm = int(input())
for _ in range(hm):
	inp = list(input())
	ac = inp.count('A') + inp.count('C')
	b = inp.count('B')
	if ac - b == 0:
		print('YES')
	else:
		print('NO')


import math as m
x = int(input())
y = [str(input()) for i in range(x)]

def f(s, z):
	return len(s) - len(s.replace(z, ''))
for i in range(len(y)):
	if f(y[i], 'A') + f(y[i], 'B') == f(y[i], 'C') and f(y[i], 'A') == f(y[i], 'B') and (f(y[i], 'A') != 1) or (f(y[i], 'A') + f(y[i], 'B') == f(y[i], 'C') and f(y[i], 'B') == f(y[i], 'C')):
		print('YES')
	elif f(y[i], 'B') + f(y[i], 'C') == f(y[i], 'A') and f(y[i], 'B') == f(y[i], 'C') and (f(y[i], 'B') != 1) or (f(y[i], 'B') + f(y[i], 'C') == f(y[i], 'A') and f(y[i], 'B') == f(y[i], 'A')):
		print('YES')
	elif f(y[i], 'C') + f(y[i], 'A') == f(y[i], 'B') and f(y[i], 'C') == f(y[i], 'A') and (f(y[i], 'C') != 1) or (f(y[i], 'C') + f(y[i], 'A') == f(y[i], 'B') and f(y[i], 'C') == f(y[i], 'B')) or (f(y[i], 'C') + f(y[i], 'A') == f(y[i], 'B') and f(y[i], 'A') == f(y[i], 'B')):
		print('YES')
	elif f(y[i], 'C') + f(y[i], 'A') == f(y[i], 'B'):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	w = s.count('A') + s.count('C')
	if w == s.count('B'):
		print('YES')
	else:
		print('NO')


i = int(input())
for j in range(i):
	s = input()
	count = 0
	for i in s:
		if i == 'A':
			count += 1
		elif i == 'B':
			count -= 1
		elif i == 'C':
			count += 1
	if count == 0:
		print('YES')
	else:
		print('NO')


def main():

	def solve(s):
		ac = b = 0
		for c in s:
			if c == 'B':
				b += 1
			else:
				ac += 1
		return 'YES' if ac == b else 'NO'
	t = int(input())
	for _ in range(t):
		s = input().strip()
		print(solve(s))
import sys, threading
input = sys.stdin.readline
thread = threading.Thread(target=main)
thread.start()
thread.join()


t = int(input())

def func(s):
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if a + c != b:
		return 'NO'
	return 'YES'
for i in range(t):
	s = input()
	print(func(s))


from collections import defaultdict, deque
from heapq import heappush, heappop
from math import inf
ri = lambda : map(int, input().split())
ro = lambda : int(input())

def solve():
	s = input()
	n = len(s)
	if n & 1:
		print('NO')
		return
	cnt = defaultdict(int)
	for c in s:
		cnt[c] += 1
	(a, b, c) = ('A', 'B', 'C')
	if cnt[b] < cnt[a]:
		print('NO')
		return
	cnt[b] -= cnt[a]
	if cnt[b] < cnt[c]:
		print('NO')
		return
	cnt[b] -= cnt[c]
	if cnt[b] == 0:
		print('YES')
	else:
		print('NO')
t = 1
t = int(input())
while t:
	t -= 1
	solve()


t = int(input())
for _ in range(t):
	s = input()
	if len(s) & 1 or s.count('B') != len(s) // 2:
		print('NO')
	else:
		print('YES')


def solution(string):
	counter = {'A': 0, 'B': 0, 'C': 0}
	for character in string:
		counter[character] += 1
	return counter['A'] + counter['C'] == counter['B']

def main():
	n = int(input())
	for _ in range(n):
		string = input()
		if solution(string):
			print('YES')
		else:
			print('NO')
main()


t = int(input())
for _ in range(t):
	s = input()
	cnt = 0
	for e in s:
		if e == 'B':
			cnt += 1
	print(['NO', 'YES'][cnt == len(s) - cnt])


import sys

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

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

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(s):
	a = 0
	b = 0
	c = 0
	for ele in s:
		if ele == 'A':
			a += 1
		elif ele == 'B':
			b += 1
		else:
			c += 1
	if a + c != b:
		print('NO')
	else:
		print('YES')
T = get_int()
while T:
	s = get_string()
	solve(s)
	T -= 1


a = int(input())
for i in range(a):
	b = input()
	if b.count('A') + b.count('C') == b.count('B'):
		print('YES')
	else:
		print('NO')


santhosh = int(input())
for _ in range(santhosh):
	sandy = input()
	bcounting_varible = sandy.count('B')
	ccounting_varibles = sandy.count('C')
	acounting_varible = sandy.count('A')
	if acounting_varible + ccounting_varibles == bcounting_varible:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = str(input())
	countA = b.count('A')
	countB = b.count('B')
	countC = b.count('C')
	result = countB - (countA + countC)
	if result == 0:
		print('YES')
	else:
		print('NO')


(a, d) = (int(input()), [])
for i in range(0, a):
	b = input()
	if len(b) % 2 == 1:
		d.append('NO')
	elif b.count('A') + b.count('C') == b.count('B'):
		d.append('YES')
	else:
		d.append('NO')
print(*d, sep='\n')


t = int(input())

def rem(lis, it):
	for i in lis:
		lis.remove(i)
	return lis

def count(res):
	a = 0
	b = 0
	c = 0
	for i in range(len(res)):
		if res[i] == 'A':
			a = a + 1
		if res[i] == 'B':
			b = b + 1
		if res[i] == 'C':
			c = c + 1
	return (a, b, c)
while t > 0:
	test = input()
	res = list(test)
	cc = count(res)
	a = cc[0]
	b = cc[1]
	c = cc[2]
	if b == a + c:
		print('YES')
	else:
		print('NO')
	t = t - 1


from sys import stdin
from io import StringIO
input = lambda : stdin.readline().strip()
linput = lambda : [*map(int, input().split())]

def main():
	s = input()
	if s.count('B') == s.count('A') + s.count('C'):
		print('YES')
	else:
		print('NO')
for _ in ' ' * int(input()):
	main()


from collections import defaultdict
m = int(input())
ans = []
for _ in range(m):
	d = defaultdict(int)
	s = str(input())
	for i in s:
		d[i] += 1
	ans.append('YES' if d['A'] + d['C'] == d['B'] else 'NO')
for i in ans:
	print(i)


n = int(input())
s = list()
for i in range(n):
	s.append(input())
l = list()
for j in s:
	ca = 0
	cb = 0
	cc = 0
	l.clear()
	l = list(j)
	for k in l:
		if k == 'A':
			ca += 1
		elif k == 'B':
			cb += 1
		else:
			cc += 1
	cn = cc + ca
	if cn == cb:
		print('YES')
	else:
		print('NO')


num = int(input())
cases = [input() for _ in range(num)]
for _str in cases:
	print('YES' if _str.count('B') == _str.count('A') + _str.count('C') else 'NO')


t = int(input())
for i in range(t):
	s = input()
	if len(s) % 2 != 0:
		print('NO')
		continue
	d = dict()
	for i in s:
		d[i] = d.get(i, 0) + 1
	if 'C' not in d.keys():
		d['C'] = 0
	if 'B' not in d.keys():
		d['B'] = 0
	if 'A' not in d.keys():
		d['A'] = 0
	if d['A'] + d['C'] == d['B']:
		print('YES')
	else:
		print('NO')


from collections import Counter

def main():
	s = input()
	c = Counter(s)
	if c['A'] + c['C'] == c['B']:
		print('YES')
	else:
		print('NO')
t = int(input())
while t > 0:
	t -= 1
	main()


from sys import stdin, stdout

def II():
	return int(stdin.readline())

def SI():
	return stdin.readline()[:-1]

def solve():
	s = SI()
	l = len(s)
	if l == 0:
		stdout.write('YES\n')
		return
	(a, b, c) = (0, 0, 0)
	for x in s:
		if x == 'A':
			a += 1
		elif x == 'B':
			b += 1
		elif x == 'C':
			c += 1
	l = b - a - c
	if l == 0:
		stdout.write('YES\n')
	else:
		stdout.write('NO\n')
t = II()
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	a = input()
	n = len(a)
	A = a.count('A')
	B = a.count('B')
	C = a.count('C')
	if B == A + C:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	s = input()
	a = s.count('B')
	if a == len(s) // 2 and len(s) % 2 == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = list(input())
	acount = s.count('A')
	bcount = s.count('B')
	ccount = s.count('C')
	length = len(s)
	ab_min = min(acount, bcount)
	length = length - 2 * ab_min
	acount = acount - ab_min
	bcount = bcount - ab_min
	length = length - 2 * min(bcount, ccount)
	if length == 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	count_a = 0
	count_b = 0
	count_c = 0
	for j in range(len(s)):
		if s[j] == 'A':
			count_a += 1
		elif s[j] == 'B':
			count_b += 1
		else:
			count_c += 1
	if count_b == count_c + count_a:
		print('YES')
	else:
		print('NO')


count = int(input())
for i in range(0, count):
	string = input()
	aCount = string.count('A')
	bCount = string.count('B')
	cCount = string.count('C')
	acCount = aCount + cCount
	if len(string) % 2 != 0:
		print('NO')
	elif acCount == bCount:
		print('YES')
	else:
		print('NO')


for _ in range(int(input().strip())):
	s = input().strip()
	b_count = s.count('B')
	a_count = s.count('A')
	c_count = s.count('C')
	if b_count == a_count + c_count:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	s = input()
	if s.count('B') == len(s) / 2:
		print('YES')
	else:
		print('NO')


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

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

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	st = input()
	a = 0
	b = 0
	c = 0
	for i in st:
		if i == 'A':
			a += 1
		elif i == 'B':
			b += 1
		else:
			c += 1
	if c > b:
		print('NO')
		continue
	b -= c
	if a != b:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	s = input()
	(a, b, c) = (0, 0, 0)
	for i in range(len(s)):
		if s[i] == 'A':
			a += 1
		if s[i] == 'B':
			b += 1
		if s[i] == 'C':
			c += 1
	if a + c == b:
		print('YES')
	else:
		print('NO')


def casimir(N):
	b = 0
	for i in N:
		if i == 'B':
			b += 1
	a = float(len(N) / 2)
	if a == b:
		print('YES')
	else:
		print('NO')
t = int(input())
for i in range(t):
	A = str(input())
	casimir(A)


a = input()
while True:
	try:
		cin = input()
		ca = 0
		cb = 0
		cc = 0
		for i in cin:
			if i == 'A':
				ca += 1
			if i == 'B':
				cb += 1
			if i == 'C':
				cc += 1
		if ca == cb - cc:
			print('YES')
		else:
			print('NO')
	except:
		break


n = int(input())
for _ in range(n):
	l = list(input())
	count_A = len([i for i in l if i == 'A'])
	count_B = len([i for i in l if i == 'B'])
	count_C = len([i for i in l if i == 'C'])
	if count_C + count_A == count_B or l in ['AB', 'BC', 'BA', 'CB']:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	b = 0
	n = len(s)
	for item in s:
		if item == 'B':
			b += 1
	if n % 2 != 0:
		print('NO')
	elif b == int(n / 2):
		print('YES')
	else:
		print('NO')


times = int(input())
for i in range(times):
	question = input()
	now = [question.count('A'), question.count('B'), question.count('C')]
	if now[1] == now[0] + now[2]:
		print('YES')
	else:
		print('NO')


t = eval(input())
for i in range(t):
	sum1 = sum2 = sum3 = 0
	a = input()
	for j in a:
		if j == 'A':
			sum1 = sum1 + 1
		elif j == 'B':
			sum2 = sum2 + 1
		else:
			sum3 = sum3 + 1
	if sum1 + sum3 == sum2:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	if len(s) % 2 == 0:
		while 'A' in s and 'B' in s:
			s = s.replace('A', '', 1)
			s = s.replace('B', '', 1)
		while 'B' in s and 'C' in s:
			s = s.replace('B', '', 1)
			s = s.replace('C', '', 1)
		if s:
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


import math
import sys
import collections
import bisect
import time
import random
import itertools
import string
from collections import Counter, defaultdict

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	s = list(get_string())
	(a, b, c) = (s.count('A'), s.count('B'), s.count('C'))
	if b >= a and b - a == c:
		print('YES')
	else:
		print('NO')


t = int(input())
while t != 0:
	t -= 1
	s = input()
	if len(s) % 2 != 0:
		print('NO')
	else:
		a = s.count('A')
		b = s.count('B')
		c = s.count('C')
		if b == a + c:
			print('YES')
		else:
			print('NO')


from bisect import bisect_left as bl
n = int(input())
for i in range(n):
	s = input()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if a + c == b:
		print('YES')
	else:
		print('NO')


def f(s: list):
	if len(s) < 2:
		return 'no'
	ca = s.count('A')
	i = 0
	while i < ca:
		s.remove('A')
		if 'B' in s:
			s.remove('B')
		else:
			return 'no'
		i += 1
	i = 0
	cb = s.count('B')
	while i < cb:
		s.remove('B')
		if 'C' in s:
			s.remove('C')
		else:
			return 'no'
		i += 1
	if s:
		return 'no'
	else:
		return 'yes'
t = int(input())
for i in range(t):
	s = list(input())
	print(f(s).upper())


t = int(input())
while t:
	s = input()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	min_ab = min(a, b)
	min_bc = min(b, c)
	if min_ab > -1:
		a = a - min_ab
		b = b - min_ab
	if min_bc > -1:
		b = b - min_bc
		c = c - min_bc
	if a == b == c:
		print('YES')
	else:
		print('NO')
	t -= 1


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	s = input().rstrip()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if a + c == b:
		print('YES')
	else:
		print('NO')


from collections import Counter

def main():
	t = int(input())
	for i in range(t):
		s = input()
		ocurrences = Counter(s)
		if ocurrences['B'] == ocurrences['A'] + ocurrences['C']:
			print('YES')
		else:
			print('NO')
main()


from collections import Counter
for _ in range(int(input())):
	s = input()
	d = Counter(s)
	if d.get('B') == None:
		print('NO')
	else:
		a = c = 0
		if d.get('A') != None:
			a = d['A']
		if d.get('C') != None:
			c = d['C']
		if a + c == d['B']:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(0, n):
	l = list(map(str, input()))
	while 'A' in l and 'B' in l:
		l.remove('A')
		l.remove('B')
	while 'C' in l and 'B' in l:
		l.remove('C')
		l.remove('B')
	if len(l) == 0:
		print('YES')
	else:
		print('NO')


def cst(s):
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if len(s) == 0:
		return True
	if c == 0:
		return a == b
	elif a == 0:
		return b == c
	elif b == 0:
		return False
	return a + c == b
for _ in range(int(input())):
	flg = cst(str(input()))
	if flg:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = str(input())
	b = a.count('A')
	c = a.count('B')
	d = a.count('C')
	if len(a) % 2 == 0 and b + d == c:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	l = input()
	(s_a_c, s_b) = (0, 0)
	for el in l:
		if el in ['A', 'C']:
			s_a_c += 1
		else:
			s_b += 1
	if s_a_c == s_b:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = input()
	k = len(n)
	ao = 0
	bo = 0
	co = 0
	for i in range(k):
		if n[i] == 'A':
			ao = ao + 1
		elif n[i] == 'B':
			bo = bo + 1
		elif n[i] == 'C':
			co = co + 1
	if ao + co == bo:
		print('YES')
	else:
		print('NO')
	t = t - 1


import math
from collections import defaultdict, Counter
for t in range(int(input())):
	s = input()
	d = Counter(s)
	if d['C'] + d['A'] == d['B']:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	str1 = input()
	count_a = str1.count('A')
	count_b = str1.count('B')
	count_c = str1.count('C')
	if len(str1) % 2 != 0:
		print('NO')
	elif count_a + count_c == count_b:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = input()
	res = list(n)
	res = sorted(res)
	ca = res.count('A')
	cb = res.count('B')
	cc = res.count('C')
	if ca > cb:
		print('NO')
	elif ca <= cb:
		x = cb - ca
		if x == cc:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	t = t - 1


t = int(input())
for i in range(0, t):
	s = input()
	v = 0
	c1 = s.count('A')
	c2 = s.count('B')
	c3 = s.count('C')
	if c2 > c1 + c3:
		v += 2 * (c1 + c3)
	elif c2 <= c1 + c3:
		v += 2 * c2
	if len(s) - v == 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	a = input()
	ac = 0
	bc = 0
	cc = 0
	for j in range(len(a)):
		if a[j] == 'A':
			ac = ac + 1
		if a[j] == 'B':
			bc = bc + 1
		if a[j] == 'C':
			cc = cc + 1
	if bc == ac + cc:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	n = input()
	d = {'A': 0, 'B': 0, 'C': 0}
	for i in n:
		if i in d:
			d[i] += 1
		else:
			d[i] = 0
	if d['A'] + d['C'] == d['B']:
		print('YES')
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	string = input()
	if string.count('B') == string.count('A') + string.count('C'):
		print('YES')
	else:
		print('NO')


def func1(str1):
	(cA, cB, cC) = (0, 0, 0)
	for char1 in str1:
		if char1 == 'A':
			cA += 1
		elif char1 == 'B':
			cB += 1
		else:
			cC += 1
	if cA + cC == cB:
		return True
	return False
n = int(input())
for i in range(n):
	temp = input()
	if func1(temp):
		print('YES')
	else:
		print('NO')


numberofentries = int(input())
while numberofentries > 0:
	letters = str(input())
	lengthofletters = len(letters)
	if letters.count('B') == len(letters) / 2:
		print('YES')
	else:
		print('NO')
	numberofentries -= 1


t = int(input())
lst = []
for i in range(t):
	f = input()
	a = 0
	b = 0
	c = 0
	for j in f:
		if j == 'C':
			c += 1
		elif j == 'A':
			a += 1
		else:
			b += 1
	if b == a + c:
		lst.append('YES')
	else:
		lst.append('NO')
for i in range(t):
	print(lst[i])


t = int(input())
r = []
for i in range(t):
	s = input()
	if len(s) % 2 != 0:
		r.append('NO')
	elif s.find('B') == -1:
		r.append('NO')
	else:
		f = s.count('B')
		if f != len(s) // 2:
			r.append('NO')
		else:
			r.append('YES')
for i in range(len(r)):
	print(r[i])


t = int(input())
a = list()
for i in range(t):
	a.append(list(input()))
b = list()
for i in range(t):
	d = dict()
	for elem in a[i]:
		if elem not in d:
			d[elem] = 1
		else:
			d[elem] += 1
	b.append(d)
for i in range(t):
	if len(b[i]) == 3:
		if b[i]['B'] == b[i]['A'] + b[i]['C']:
			print('YES')
		else:
			print('NO')
	elif len(b[i]) == 1:
		print('NO')
	elif 'B' not in b[i]:
		print('NO')
	elif 'C' not in b[i] and b[i]['B'] == b[i]['A']:
		print('YES')
	elif 'C' not in b[i] and b[i]['B'] != b[i]['A']:
		print('NO')
	elif 'A' not in b[i] and b[i]['B'] == b[i]['C']:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	a_c = s.count('A')
	b_c = s.count('B')
	c_c = s.count('C')
	if a_c <= b_c and b_c - a_c == c_c:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	a = s.count('A')
	b = s.count('B')
	c = s.count('C')
	if b >= a:
		b = b - a
		if b == c:
			print('YES')
		else:
			print('NO')
	elif b >= c:
		b = b - c
		if b == a:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')