#include
#include
using namespace std;
int main()
{
int n,i,j,c,a1,a2;
cin>>n;
string s;
for(i=0;i<n;i++)
{ c=0;
cin>>s;
j=0;
while( s[j]==’.’)
j++;
while( s[j]!=’\0’)
{a1=s[j];
j++;
while( s[j]==’.’)
{j++; c++;}
a2=s[j];
if(c<a2+a1-96) {cout<<“unsafe\n”; break;}
}
if(s[j]==’\0’) cout<<“safe\n”;
}
return 0;
}