Thef and his Games

In a far away Galaxy of Tilky Way, there was a planet Tarth where the sport of Tompetitive Toding was very popular. According to legends, there lived a setter known to give advanced string manipulation problems disguised as cakewalk problems.

thef, the king of thefland loved the letter ‘t’. And now, he has made a game on it with his ministers! His ministers would give him 22 strings, aa and bb. thef has to make them exactly same, for which he can do the following-

Step 1 - He MAY reverse at most one of the strings. (This step is optional, and he can choose to reverse any one of the strings, or leave both of them as it is.)

Step 2 - He replaces the first character of both the current strings to ‘t’. This operation is compulsory.

He wins if he is able to make both the strings same (i.e. an exact match) after doing these two steps. Given the strings aa and bb, tell if thef can win or not!


  • The first line of input contains TT - The number of test cases in the file.
  • The first and only line of every test case contains the 22 strings, aa and bb separated by a single space.


For each test case, print Yes if thef wins, else print No


  • 1≤T≤1041≤T≤104
  • 1≤|a|,|b|≤1001≤|a|,|b|≤100, where |a||a| refers to the length of string aa.
  • aa and bb will have ONLY lower case English alphabets.


  • 100 points- Original Constraints.

Sample Input:

man nam
abcd ebcd
abd ebf

Sample Output:



  • For the first test case, you can reverse manman to namnam and then replace both first characters of both strings to get tamtam. You could also have reversed nam nam to man man, and then replaced the first two characters to get tantan. Either of these two methods leads thef to win the game.
  • For the second test case, you can simply skip reversing any of the strings and just replace the first characters by tt to get both the strings as tbcd tbcd.
  • The 22 strings cannot be made equal in the third test case.


Date Added:10-09-2019

Time Limit:1 secs

Source Limit:50000 Bytes