#include <bits/stdc++.h>
using namespace std;
int main(){
string a,b;
int n;
cin>>n;
int c=0;
int j1,s;
int w=0;
for(int i=1;i<=n;i++){
c=0;
j1=0;
w=0;
s=0;
cin>>a>>b;
if(a.size()==b.size()){
j1=a.size();
for(int j=1;j<=a.size();j++){
if(a[j1--]!=b[j1--]){
c++;
}
}
if(c<=1){
cout<<"similar"<<endl;
}else{
cout<<"not similar"<<endl;
}
}else{
if(a.size()==b.size()+1 || a.size()==b.size()-1 ){
if(a.size()>b.size()){
for(int h=1;h<=b.size();h++){
s=h+w;
if(b[h]!=a[s]){
c++;
w++;
}
}
}else{
for(int h=1;h<=a.size();h++){
s=h+w;
if(b[s]!=a[h]){
c++;
w++;
}
}
if(c<=1){
cout<<"similar"<<endl;
}else{
cout<<"not similar"<<endl;
}
}
}else{
cout<<"not similar"<<endl;
}
}
}
}