#include <iostream>
#include <cstring>
using namespace std;
void Y(){cout<<"similar\n";}
void N(){cout<<"not similar\n";}
int main(){
int T; cin>>T;
while(T--){
string a, b; cin>>a>>b;
if(a.size()<b.size()) swap(a, b);
if(a.size()-b.size()>1) N();
if(a.size()-b.size()==1){
int h=0, fl=0;
for(int i=0; i<b.size(); ++i){
if(a[h+i]!=b[i]){
if(h==0) h++;
else{N(); fl++; break;}
}
}
if(fl==0) Y();
}
if(a.size()==b.size()){
int h=0;
for(int i=0; i<a.size(); ++i) if(a[i]!=b[i]) h++;
if(h<2) Y();
else N();
}
}
}