/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
bool areSame(string s1, string s2, int n)
{
for (int i = 0; s1[i] != '\0'; i++)
{
if (s1.at(i) != s2.at(i))
{
return false;
}
}
return true;
}
int main()
{
int t;
cin >> t;
while (t--)
{
string s1, s2;
cin >> s1 >> s2;
if (s1 == s2)
{
cout << "YES" << endl;
}
else
{
int n1 = s1.length();
int n2 = s2.length();
if (n1 == n2)
{
if (n1 & 1)
{
cout << "NO" << endl;
}
else
{
if ((areSame(s1.substr(0, (n1 / 2) - 1), s2.substr(0, (n1 / 2) - 1), n1 / 2)) && areSame(s1.substr((n1 / 2) + 1), s2.substr((n1 / 2) + 1), n1 / 2) ||
(areSame(s1.substr(0, (n1 / 2) - 1), s2.substr((n1 / 2) + 1), n1 / 2) && areSame(s1.substr(0, (n1 / 2) - 1), s2.substr((n1 / 2) + 1), n1 / 2)))
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
}
}
else
{
cout << "NO" << endl;
}
}
}
return 0;
}