#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 A; string S; void init(string &T){ S=T; A.assign(S.size()+1,0); A[0]=-1; int j=-1; for(int i=0;i=0&&S[i]!=S[j]) j=A[j]; j++; A[i+1]=j; } } vector match(string &C,string &T){ init(C); vector B; int m=0,i=0; while(m+i0) i=A[i]; } } return B; }//C(=S)がTの中に含まれる開始位置を返す }; 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--){ bool f=false; string S,T;cin>>S>>T; if(si(S)>si(T)){ swap(S,T); f=true; } if(si(S)==si(T)){ if(S