#include<bits/stdc++.h>
using namespace std;
int t;
char a[55],b[55];
deque<char> q1;
deque<char> q2;
bool simi(string a,string b){
int m=a.length();
int n=b.length();
// cout<<1;
// cout<<m<<n<<endl;
if(abs(m-n)>1){
// cout<<2;
return false;
}
else if(m==n){
for(int i=1;i<=m;i++){
if(a[i]!=b[i]) return false;
}
}else{
// cout<<1;
int cishu=1;
int x=min(m,n);
int y=max(m,n);
if(x==n) swap(a,b);
for(int i=0;i<x;i++) q1.push_back(a[i]);
for(int j=0;j<y;j++) q2.push_back(b[j]);
while(!q2.empty()){
if(!q2.empty()&&q1.empty()&&cishu==1&&q2.size()==1){
q2.pop_front();
return true;
}
else if(!q2.empty()&&q1.empty()){
while(!q2.empty()){
q2.pop_front();
}
return false;
}
while(!q1.empty()){
if(cishu<0) return false;
char b1=q1.front();
char b2=q2.front();
if(b1!=b2){
// cout<<1;
cishu--;
q2.pop_front();
}else{
q1.pop_front();
q2.pop_front();
}
}
}
}
return true;
}
int main(){
cin>>t;
while(t--){
cin>>a>>b;
if(simi(a,b)==true){
cout<<"similar"<<endl;
}else{
cout<<"not similar"<<endl;
}
}
return 0;
}