#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); const int C = 26; int Q; cin >> Q; while (Q--) { string S, T; cin >> S >> T; int N = (int)S.size(); vector> A(2, vector(C)); vector> B(2, vector(C)); for (int i = 0; i < N; i++) { A[i % 2][S[i] - 'a']++; B[i % 2][T[i] - 'a']++; } if (A != B) { cout << "No\n"; continue; } if (N > 52) { cout << "Yes\n"; continue; } queue que; unordered_set seen; seen.insert(S); que.push(S); bool ok = false; int steps = 0; while (!que.empty() && steps < 1000) { string U = que.front(); que.pop(); steps++; if (U == T) { ok = true; break; } for (int i = 0; i + 3 < N; i++) { string V = U; swap(V[i], V[i + 2]); swap(V[i + 1], V[i + 3]); if (seen.insert(V).second) que.push(V); } } cout << (ok ? "Yes" : "No") << '\n'; } return 0; }