#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<functional>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
vector<int> map[10][10];
bool check(vector<int> line,int cul,int start){
    REP(i,10){
        vector<int> nline;
        REP(j,line.size()){
            REP(k,map[cul][i].size()){
                if(line[j]&map[cul][i][k])continue;
                nline.push_back(line[j]|map[cul][i][k]);
            }
        }
        sort(ALL(nline));
        nline.erase(unique(ALL(nline)),nline.end());
        if(nline.size()==0)continue;
        if(start == i)return true;
        if(check(nline,i,start))return true;
    }
    return false;
}
string func(){
    string str;
    cin >> str;
    REP(i,10){
        REP(j,10){
            map[i][j].clear();
        }
    }
    int num = 0;
    REP(i,str.size()){
        if(str[i] == 'u'){
            num = 0;
        }else{
            int nn = str[i] - '0';
            if(num != 0){
                if(num & BIT(nn))return "UNSAFE";
                REP(j,10){
                    if(BIT(j) & num){
                        map[j][nn].push_back(num);
                    }
                }
            }
            num |= BIT(nn);
        }
    }
    REP(i,10){
        REP(j,10){
            sort(ALL(map[i][j]));
            map[i][j].erase(unique(ALL(map[i][j])),map[i][j].end());
        }
    }
    REP(i,10){
        REP(j,10){
            if(check(map[i][j],j,i))return "UNSAFE";
        }
    }
    return "SAFE";
}
int main(){
    int n;
    while(cin >> n && n){
        cout << func() << endl;
    }
    return 0;
}

