#include<bits/stdc++.h>
using namespace std;
bool match(string a,string b)
{
int length=a.length()-b.length();
if(a==b) return true;
else if(length>=2 || length<=-2)
{
return false;
}
else
{
if(a.length()==b.length())
{
int num;
for(int i=0;i<a.length();i++)
if(a[i]!=b[i]) num++;
if(num>1)
{
return false;
}
else return true;
}
string l,s;
if(a.length()>b.length()) l=a,s=b;
else l=b,s=a;
int tem=0,ans=0,num=0;
while(tem<l.length() && ans<s.length())
{
if(s[ans]!=l[tem])
{
tem++;
num++;
if(num>1)
{
return false;
}
}
else ans++,tem++;
}
return true;
}
}
int main()
{
string a,b;
int t;
cin>>t;
while(t)
{
cin>>a>>b;
if(match(a,b)) cout<<"similar"<<endl;
else cout<<"not similar"<<endl;
t--;
}
}