Two sisters, A and B, play the piano every day. During the day, they can play in any order. That is, A might play first and then B, or it could be B first and then A. But each one of them plays the piano exactly once per day. They maintain a common log, in which they write their name whenever they play.
You are given the entries of the log, but you're not sure if it has been tampered with or not. Your task is to figure out whether these entries could be valid or not.

-----Input-----
- The first line of the input contains an integer $T$ denoting the number of test cases. The description of the test cases follows.
- The first line of each test case contains a string $s$ denoting the entries of the log.

-----Output-----
- For each test case, output yes or no according to the answer to the problem.

-----Constraints-----
- $1 \le T \le 500$
- $2 \le |s| \le 100$
- $|s|$ is even
- Each character of $s$ is either 'A' or 'B'

-----Example Input-----
4
AB
ABBA
ABAABB
AA

-----Example Output-----
yes
yes
no
no

-----Explanation-----
Testcase 1: There is only one day, and both A and B have played exactly once. So this is a valid log. Hence 'yes'.
Testcase 2: On the first day, A has played before B, and on the second day, B has played first. Hence, this is also a valid log.
Testcase 3: On the first day, A played before B, but on the second day, A seems to have played twice. This cannot happen, and hence this is 'no'.

Difficulty: interview

Starter code:

Solutions:
def checkValidity(s):
 count = 0
 previous = ""

 for x in s:
  if count == 0:
   previous = x
   count += 1
  elif count == 1:
   count = 0
   if previous == x:
    return "no"

 return "yes"

t = int(input())

for _ in range(t):
 s = input()
 print(checkValidity(s))


n=int(input())
l=[]
for i in range(0,n):
 s=input()
 for j in range(0,len(s),2):
  if (s[j]=='A' and s[j+1]=='B') or (s[j]=='B' and s[j+1]=='A'):
   count=1 
  else:
   l.append("no")
   count=0
   break
 if count==1:       
  l.append("yes")
for i in l:
 print(i)


# cook your dish here
t=int(input())
for _ in range(t):
 s=input()
 c=0
 for i in range(0,len(s)-1,2):
  if((s[i]=='B' and s[i+1]=='A') or (s[i]=='A' and s[i+1]=='B')):
   pass
  else:
   c=1
   break
 if(c==1):
  print("no")
 else:
  print("yes")

# cook your dish here
T=int(input())
for i in range(0,T):
 s=input()
 x=True
 for j in range(0,len(s)-1,2):
  if (s[j]=="A" and s[j+1]=="B") or (s[j]=="B" and s[j+1]=="A"):
   continue
   
  else:
   x=False
   break
 if x==True:
  print("yes")
 else:
  print("no")

'''
  Problem : Id and Ship
  Author @ Rakesh Kumar
  cpp.rakesh@gmail.com
  Date : 04/02/2021
'''

def solve():
 for _ in range(int(input())):
  s = str(input())
  r = 'yes'
  for i in range(0, len(s), 2):
   if s[i] == s[i + 1]:
    r = 'no'
    break
  print(r)

def __starting_point():
 solve()

__starting_point()

# cook your dish here
n=int(input())
for i in range(n):
 str1=input().strip()
 i=0
 while i<len(str1)-1:
  if str1[i]=='A' and str1[i+1]=='B' or str1[i]=='B' and str1[i+1]=='A':
   i+=2
   c=0
  else:
   c=1
   break
 if c!=0:
  print('no')
 else:
  print('yes')


for _ in range(int(input())):
 s = input()
 if len(s) & 1 == 1:
  print("no")
 else:
  for i in range(0, len(s), 2):
   x = s[i:i+2]
   if x == "AA" or x == "BB":
    print("no")
    break
  else:
   print("yes")

t=int(input())
for i in range (t):
 s=input()
 x=0
 y=2
 count=0
 for i in range(len(s)//2):
  a=s[x:y]
  if "A" in a and "B" in a :
   count=count+1
  else:
   count=count
  x=x+2
  y=y+2
 if count==len(s)//2:
  print("yes")
 else:
  print("no")


# cook your dish here
T=int(input())
for i in range(T):
 s=input()
 x=0
 y=2
 count=0
 for i in range(len(s)//2):
  a=s[x:y]
  if "A" in a and "B" in a :
   count=count+1
  else:
   count=count
  x=x+2
  y=y+2
 if count==len(s)//2:
  print("yes")
 else:
  print("no")

# cook your dish here
for _ in range(int(input())):
 s=input()
 for i in range(0,len(s),2):
  if (s[i]=='A' and s[i+1]=='B') or (s[i]=='B' and s[i+1]=='A'):
   c=1 
  else:
   print("no")
   c=0
   break
 if c==1:
  
  print("yes")

# cook your dish here
n=int(input())
for i in range(0,n):
 c=0
 s=input()
 for j in range(0,len(s),2):
  if(s[j]==s[j+1]):
   c=c+1
 if(c>0):
  print("no")
 else:
  print("yes")


# cook your dish here
n=int(input())
while n!=0:
 i=0
 flag=True
 string=input()
 while i<=(len(string)-2):
  if string[i]==string[i+1]:
   print('no')
   flag=False
   break
  else:
   i+=2
 if flag==True:
  print('yes')
 n-=1

# cook your dish here
n=int(input())
for i in range(0,n):
 c=0
 s=input()
 for j in range(0,len(s),2):
  if(s[j]==s[j+1]):
   c=c+1
 if(c>0):
  print("no")
 else:
  print("yes")

# cook your dish here
t=int(input())
for _ in range(t):
 s=input()
 list_of_strings=[]
 count=0
 for i in range(0,len(s),2):
  list_of_strings.append(s[i:i+2])
 for i in list_of_strings:
  if(i=='AB'):
   count+=1
  elif(i=='BA'):
   count+=1
 k=len(list_of_strings)
 if(count==k):
  print("yes")
 else:
  print("no")


t=int(input())
while t>0:
 s=input()
 i=fl=0
 while i<len(s):
  if s[i]==s[i+1]:
   fl=1 
   break 
  i+=2
 if fl==0:
  print("yes")
 elif fl==1:
  print("no") 
 t-=1


for i in range(int(input())):
 s = list(input())
 for i in range(0,len(s),2):
  if s[i] == s[i + 1]:
   print("no")
   break
  else:
   if i == len(s)-2:
    print("yes")
    break
   else:
    continue


# cook your dish here
def piano(s):
 acount=s.count('A')
 bcount=s.count('B')
 if acount!=bcount:
  return False 
 for i in range(0,len(s)-1,2):
  if s[i]==s[i+1]:
   return False 
 return True
for _ in range(int(input())):
 s=list(input())
 if piano(s):
  print("yes")
 else:
  print("no")

# cook your dish here
def piano(s):
 acount=s.count('A')
 bcount=s.count('B')
 if acount!=bcount:
  return False 
 for i in range(0,len(s)-1,2):
  if s[i]==s[i+1]:
   return False 
 return True
for _ in range(int(input())):
 s=list(input())
 if piano(s):
  print("yes")
 else:
  print("no")

# cook your dish here
t=int(input())
for ts in range(t):
 n=input()
 c=0
 for i in range(0,len(n)-1,2):
  if ((n[i]=='A' and n[i+1]=='B') or (n[i]=='B' and n[i+1]=='A')):
   c+=1
 if(c==len(n)//2):
  print('yes')
 else:
  print('no')

# cook your dish here
t=int(input())
for j in range(t):
 s=input()
 a=0
 for i in range(0,len(s)-1,2):
  if((s[i]=='A' and s[i+1]=='B') or (s[i]=='B' and s[i+1]=='A')):
   a=a+1
 if a==len(s)/2:
  print("yes")
 else:
  print("no")


# cook your dish here
t = int(input())
for z in range(t) :
 s = input()
 for i in range(0,len(s),2) :
  if s[i] == s[i+1] :
   print("no")
   break
 else:
  print("yes")

# cook your dish here
t=int(input())
for ts in range(t):
 n=input()
 c=0
 for i in range(0,len(n)-1,2):
  if ((n[i]=='A' and n[i+1]=='B') or (n[i]=='B' and n[i+1]=='A')):
   c+=1
 if(c==len(n)//2):
  print('yes')
 else:
  print('no')

# vivek hirpara
for _ in range(int(input())):
 s1=input()
 f=0
 for i in range(0,len(s1),2):
  if s1[i]==s1[i+1]:
   f=1
 print("yes") if f==0 else print("no") 
 
 

for _ in range(int(input())):
 s = input()
 if s.count("A") == s.count("B"):
  flag = 1
  for i in range(0,len(s),2):
   if s[i] != s[i+1]:
    pass
   else:
    flag = 0
    break
  if flag == 0:
   print("no")
  else:
   print("yes")
 else:
  print("no")

def string(s):
 x=0
 for i in range(0,len(s)-1,+2):
  if s[i]==s[i+1]:
   x=0
   return "no"
  else:
   x=1
 if x==1:
  return "yes"
for _ in range(int(input())):
 s=input()
 print(string(s))