…:
t=int(input())
d=0
f=1
for i in range(t):
s=input()
for j in range(0,len(s)):
if s[j].isdigit():
d+=1
l=j+int(s[j])
for k in range(j+1,len(s)):
if s[k].isdigit():
m=k-int(s[k])
if m<=l:
f=0
break
else:
f=1
if f==1 or d==0 or d==1:
print("safe")
else:
print("unsafe")