#include using namespace std; typedef long long ll; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b #define vl vector #define vii vector> #define vll vector> #define vvi vector> #define vvl vector> #define vvii vector>> #define vvll vector>> #define vst vector #define pii pair #define pll pair #define pb push_back #define all(x) (x).begin(),(x).end() #define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end()) #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=300005,INF=15<<26; bool solve(){ string S,T;cin>>S>>T; int N=si(S); vi CN(3); for(char c:S){ if(c=='g') CN[0]++; if(c=='o') CN[1]++; if(c=='d') CN[2]++; } for(int i=0;i<3;i++){ CN[i]*=-1; } for(char c:T){ if(c=='g') CN[0]++; if(c=='o') CN[1]++; if(c=='d') CN[2]++; } for(int i=0;i<3;i++){ if(CN[i]!=0){ return false; } } for(int q=0;q<2;q++){ vii A,X; int a=0,b=0; for(int i=0;i=3){ A.pb(mp(a-1,b)); } X.pb(mp(i,1)); b++; } } swap(A,X); mkunique(X); vi U,V,rui(N+1); for(int i=0;i=0&&x=0&&y=2){ }else{ return false; } } } swap(S,T); } return true; } int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int Q;cin>>Q; while(Q--){ if(solve()) cout<<"Yes\n"; else cout<<"No\n"; } }