#include //#include using namespace std; // using namespace atcoder; // using mint = modint1000000007; // const int mod = 1000000007; // using mint = modint998244353; // const int mod = 998244353; // const int INF = 1e9; // const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i, l, r) for (int i = (l); i < (r); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; --i) #define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define P pair template inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin >> t; while (t--) { auto chk = [&](string s, string t) { string s0, s1, t0, t1; rep(i, s.size()) { if (i % 2 == 0)s0 += s[i]; else s1 += s[i]; } rep(i, t.size()) { if (i % 2 == 0)t0 += t[i]; else t1 += t[i]; } sort(all(s0)); sort(all(s1)); sort(all(t0)); sort(all(t1)); return s0 == t0 && s1 == t1; }; string s, t; cin >> s >> t; if (!chk(s, t)) { cout << "No" << endl; continue; } auto chk1 = [&](string s) { vectorc0(26), c1(26); rep(i, s.size()) { if (i % 2 == 0)c0[s[i] - 'a']++; else c1[s[i] - 'a']++; } rep(i, 26)if (c0[i] > 1)return true; rep(i, 26)if (c1[i] > 1)return true; return false; }; if (chk1(s) || chk1(t)) { cout << "Yes" << endl; continue; } auto chk2 = [&](string s)->P { vectorc0(26), c1(26); int x0 = 0, x1 = 0; rep(i, s.size()) { if (i % 2 == 0) { rep2(j, s[i] - 'a', 26)x0 += c0[j]; c0[s[i] - 'a']++; } else { rep2(j, s[i] - 'a', 26)x1 += c1[j]; c1[s[i] - 'a']++; } //rep(j, 26)cout << c0[j]; //cout << endl; //rep(j, 26)cout << c1[j]; //cout << endl; x0 %= 2; x1 %= 2; } //cout << x0 << "_" << x1 << endl; return { x0,x1 }; }; auto p0 = chk2(s); auto p1 = chk2(t); if ((p0.first + p0.second) % 2 == (p1.first + p1.second) % 2)cout << "Yes" << endl; else cout << "No" << endl; } return 0; }