#include<bits/stdc++.h>
using namespace std;
char c[27] = {};
bool check(string a, string b){
if(a == b)
return true;
else if(a != b){
if(a.size() == b.size()){
int cnt = 0;
for(int i = 0; i < a.size(); i++){
if(a[i] != b[i]){
cnt++;
}
}
if(cnt >= 2){
return false;
}else{
return true;
}
}else if(a.size() != b.size()){
if(max(a.size(), b.size()) - min(a.size(), b.size()) >= 2){
return false;
}else{
if(b.size() < a.size()){
for(int i = 0; i < b.size(); i++){
for(int j = 0; j < 26; j++){
string b1 = b.substr(0, i) + c[j] + b.substr(i, b.size() - i);
if(b1 == a){
return true;
}
}
}
return false;
}if(b.size() > a.size()){
for(int i = 0; i < a.size(); i++){
for(int j = 0; j < 26; j++){
string a1 = a.substr(0, i) + c[j] + a.substr(i, a.size() - i);
if(a1 == b){
return true;
}
}
}
return false;
}
}
}
}
}
int main(){
for(int i = 0; i < 26; i++){
c[i] = 'a' + i;
}
int t;
cin >> t;
while(t--){
string a, b;
cin >> a >> b;
if(check(a, b)){
cout << "similar\n";
}else{
cout << "not similar\n";
}
}
return 0;
}