#include<bits/stdc++.h>
using namespace std;
bool chk(string a, string b) {
int s1 = a.size(), s2 = b.size();
if(abs(s1 - s2) >= 2)
return false;
if(s1 == s2) {
int cnt = 0;
for(int i = 0; i < s1; i++)
if(a[i] != b[i]) cnt++;
return cnt <= 1;
}
if(s1 < s2)
swap(a, b);
for(int i = 0; i <= s2; i++)
for(char c = 'a'; c <= 'z'; c++) {
string tmp = b;
tmp.insert(i, 1, c);
if(a == tmp) return true;
}
return false;
}
int main() {
int Q;
cin >> Q;
while(Q--) {
string a, b;
cin >> a >> b;
cout << (chk(a, b) ? "similar\n" : "not similar\n");
}
return 0;
}