#include #include #include #include #include #include #include #include #include #include #define LL long long #define pr pair < int, int > using namespace std; int n,m,a,b,c,w,v,k; char x[5]; map mpa,mpb,mpc; int main() { //freopen("in.txt","r",stdin); int T;scanf("%d",&T); while(T--){ scanf("%d%d%d",&a,&b,&c); getchar(); mpa.clear(); mpb.clear(); mpc.clear(); for(int i=0;i::iterator it; set l,r; for(it=mpa.begin();it!=mpa.end();++it){ l.insert(it->first); } for(it=mpb.begin();it!=mpb.end();++it){ l.insert(it->first); } for(it=mpc.begin();it!=mpc.end();++it){ r.insert(it->first); } if(l.size()!=r.size()){ puts("NO");continue; } set ::iterator itl,itr; itl=l.begin(); itr=r.begin(); bool flag=true; while(itl!=l.end()){ if(*itl!=*itr){ flag=false; break; } ++itl; ++itr; } if(!flag){ puts("NO");continue; } for(int i=1;i<=200;++i){ for(int j=1;j<=200;++j){ itl=l.begin(); char g; flag=true; while(itl!=l.end()){ g=*itl; if(mpc[g]!=mpa[g]*i+mpb[g]*j){ flag=false; break; } ++itl; } if(flag){ printf("%d %d\n",i,j); break; } } if(flag)break; } if(!flag)puts("NO"); } return 0; }