#include<bits/stdc++.h>
using namespace std;
int samenumber,now;
int main(){
int t;
cin >> t;
while(t--){
string a,b;
cin >> a >> b;
if(a == b){
cout << "similar" << endl;
continue;
}
if(a.size() == b.size()){
for(int i = 0; i < a.size(); i++){
if(a[i] == b[i]){
samenumber++;
}
}
if(a.size() - samenumber == 1){
cout << "similar" << endl;
}
else{
cout << "not similar" << endl;
}
continue;
}
if(a.size() > b.size()){
swap(a,b);
if(b.size() - a.size() > 1){
cout << "not similar" << endl;
continue;
}
}
for(int i = 0; i < b.size(); i++){
if(a[now] == b[i]){
samenumber++;
now++;
}
}
if(samenumber == a.size()){
cout << "similar" << endl;
continue;
}
cout << "not similar" << endl;
}
return 0;
}