#include using namespace std; // x[p], x[p+2], x[p+4], ... からなる部分列の転倒数の偶奇 // 前提: その部分列の文字はすべて相異なる(よって長さ 26 以下) static int invParity(const string& x, int p) { unsigned seen = 0; int par = 0; for (int i = p; i < (int)x.size(); i += 2) { int c = x[i] - 'a'; par ^= __builtin_parity(seen >> (c + 1)); // 既出で c より大きい文字数の偶奇 seen |= 1u << c; } return par; } static bool judge(const string& S, const string& T) { int cs[2][26] = {}, ct[2][26] = {}; for (int i = 0; i < (int)S.size(); i++) { cs[i & 1][S[i] - 'a']++; ct[i & 1][T[i] - 'a']++; } bool dup = false; for (int p = 0; p < 2; p++) { for (int c = 0; c < 26; c++) { if (cs[p][c] != ct[p][c]) return false; // クラス別多重集合の不一致 if (cs[p][c] >= 2) dup = true; // クラス内重複 → 符号を自由に調整可能 } } if (dup) return true; int par = invParity(S, 0) ^ invParity(S, 1) ^ invParity(T, 0) ^ invParity(T, 1); return par == 0; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int Q; cin >> Q; string S, T, out; out.reserve((size_t)Q * 4); while (Q--) { cin >> S >> T; out += judge(S, T) ? "Yes\n" : "No\n"; } cout << out; return 0; }