**Physical Address**

304 North Cardinal St.

Dorchester Center, MA 02124

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.

- 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.

- For each test case, output
`yes`

or`no`

according to the answer to the problem.

###Constraints

- 1≤
*T*≤500 - 2≤∣
*s*∣≤100 - ∣
*s*∣ is even - Each character of
*s*is either ‘A’ or ‘B’

```
Input:
4
AB
ABBA
ABAABB
AA
Output:
yes
yes
no
no
```

**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’.

```
# cook your dish here
for i in range(int(input())):
a=str(input())
i=0
res='yes'
while i < len(a):
if a[i] == a[i+1]:
res='no'
break
i+=2
print(res)
```

```
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
String s=sc.next();
int c=0;
for(int i=0;i<s.length();i+=2){
if(s.charAt(i)==s.charAt(i+1)){
c++;
break;
}
}
if(c>0){
System.out.println("no");
}else{
System.out.println("yes");
}
}
}
}
```

```
# cook your dish here
for i in range(int(input())):
s=input()
res='yes'
i=0
while i<len(s):
if s[i]==s[i+1]:
res='no'
break
i+=2
print(res)
```

In our experience, we suggest you solve this Play Piano CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Play Piano CodeChef Solution

I hope this Play Piano CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

**More Coding Solutions >>**