#include<bits/stdc++.h>
using namespace std;
#define MAX_N 100005

int n;
char s[MAX_N];
bool t[11][(1<<10)];
bool dp[11][(1<<10)];

bool check(int S){
  memset(dp,false,sizeof(dp));
  dp[0][0]=true;
  int a=1;
  for(int i=0;i<10;i++){
    if(~S>>i&1)continue;
    for(int j=0;j<(1<<10);j++){
      if(!t[i][j])continue;
      int k=(1<<10)-1-j;
      while(1){
        dp[a][j+k]|=dp[a-1][k];
        if(dp[a][j+k] && ((j+k)&S)==S )return true;
        if(k==0)break;
        k=(k-1)&(~j);
      }
    }
    a++;
  }
  return false;
}

bool solve(){
  for(int bit=0;bit<(1<<10);bit++)
    if(check(bit))return true;
  return false;
}

int main(){
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    memset(t,false,sizeof(t));
    scanf("%s",s);
    int bit=0;
    for(int i=0;i<n;i++){
      if(s[i]=='u')bit=0;
      if('0'<=s[i]&&s[i]<='9'){
        int num=s[i]-'0';
        t[ num ][ bit ] = true;
        bit|=(1<<num);
      }
    }
    if(solve())printf("UNSAFE\n");
    else printf("SAFE\n");
  }
  return 0;
}