Check if it is possible to convert one string into another with given constraints
Easy Accuracy: 15.66% Submissions: 217 Points: 2

Given two strings contains three characters i.e ‘A’, ‘B ‘and ‘#’ only. Check whether it is possible to convert the first string into another string by performing following operations on string first.
1- ‘A’ can move towards Left only
2- ‘B’ can move towards Right only
3- Neither ‘A’ nor ‘B’should cross each other
If it is possible then print “Yes” otherwise “No”.

Input:
The first line of the input contains integer T denoting the number of test cases. For each test case, there are two strings inputs str1 & str2.

Output:
For each test case, the output is a string displaying YES or NO.

Constraints:
1<=T<=100
1<=str1.length,str2.length<=20

Example:
Input:

2
#A#B#B#  A###B#B
#A#B#  #B#A#
Output:
YES
NO

Explanation:
1‘A’ in str1 is right to the ‘A’ in str2 so ‘A’ of str1 can move easily towards the left because there is no ‘B’ on its left positions and for first ‘B’ in str1 is left to the ‘B’ in str2 so ‘B’ of str2 can move easily towards the right because there is no ‘A’ on its right positions and it is same for next ‘B’ so str1 can be easily converted into str2.
2.Here first ‘A’ in str1 is left to the ‘A’ in str2 and according to the condition, ‘A’ can’t move towards right. so str1 can’t be converted into str2.