#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int q; cin >> q; auto f = [&](string s){ array cnt0{}, cnt1{}; ll s0 = 0, s1 = 0; for(int i = 0; i < (int)s.size(); i++){ int c = s[i] - 'a'; if(i % 2 == 0){ for(int j = c + 1; j < 26; j++) s0 += cnt0[j]; cnt0[c]++; }else{ for(int j = c + 1; j < 26; j++) s1 += cnt1[j]; cnt1[c]++; } } s0 &= 1, s1 &= 1; for(int i = 0; i < 26; i++){ if(cnt0[i] >= 2) s0 |= 3; } for(int i = 0; i < 26; i++){ if(cnt1[i] >= 2) s1 |= 3; } return make_tuple(cnt0, cnt1, s0, s1); }; while(q--){ string s, t; cin >> s >> t; if(s == t){ cout << "Yes\n"; continue; } auto [sC0, sC1, sS0, sS1] = f(s); auto [tC0, tC1, tS0, tS1] = f(t); if(sS0 == 3 || sS1 == 3){ cout << (sC0 == tC0 && sC1 == tC1 ? "Yes" : "No") << '\n'; }else{ cout << (sC0 == tC0 && sC1 == tC1 && ((sS0 ^ tS0) == (sS1 ^ tS1)) ? "Yes" : "No") << '\n'; } } }