#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } int tnto(string s, string t) { { auto cs = s, ct = t; sort(all(cs)); sort(all(ct)); if (cs != ct) return -1; } int n = s.size(); vector idx(26, -1); rep(i, 0, n) { int c = t[i] - 'a'; if (idx[c] != -1) return 2; idx[c] = i; } int res = 0; rep(i, 0, n) rep(j, 0, i) { if (idx[s[i] - 'a'] < idx[s[j] - 'a']) res++; } return res % 2; } void solve() { string s, t; cin >> s >> t; int n = s.size(); vector vs(2), vt(2); rep(i, 0, n) { vs[i & 1] += s[i]; vt[i & 1] += t[i]; } int t0 = tnto(vs[0], vt[0]); int t1 = tnto(vs[1], vt[1]); if (t0 == -1 || t1 == -1 || (t0 != t1 && t0 != 2 && t1 != 2)) cout << "No\n"; else cout << "Yes\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); int t = 1; cin >> t; while (t--) solve(); }