## P3 - ABBA

View as PDF

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Authors:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Jeremy really likes the Swedish rock band ABBA. So much so, he is obsessed with strings consisting of the letters A and B. He has 2 strings and , where and both only have either A or B for its letters, and is longer or as long as . Jeremy has 2 types of operations. The first operation adds an A to the end of the string. The second operation reverses the string, and then adds a B to the end of the string. He wonders if there is a sequence of operations to transform to .

#### Input Specification

The first line will be the integer , the number test cases. The next lines contains strings and , each on a separate line with before . The length of and are at most . % of points will have the length of and at most .

#### Output Specification

YES if there is can be transformed to , NO otherwise.

#### Sample Input 1

3
ABBA
ABBAAAA
AB
BABA
A
B

#### Sample Output 1

YES
YES
NO