#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) {a = b; return true;}
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if(a > b) {a = b; return true;}
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if(i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T,U> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp.first << ":" << tp.second;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        string s; cin >> s;
        vvi dp(1<<10, vi(10));
        int now = 0;
        bool safe = true;
        REP(i, n) {
            if (s[i] == 'u') {
                now = 0;
                continue;
            }
            if (now & 1<<s[i]-'0') {
                safe = false;
                break;
            }
            dp[now][s[i] - '0'] = 1;
            // DEBUG(bitset<10>(now));
            // DEBUG(s[i]);
            // cerr << endl;
            now |= 1<<s[i]-'0';
        }

        if (!safe) {
            cout << "UNSAFE" << endl;
            continue;
        }

        REP(S, 1<<10) {
            REP(i, 10) {
                if (!dp[S][i]) continue;
                REP(T, 1<<10) {
                    REP(j, 10) {
                        if (!dp[T][j]) continue;

                        // DEBUG(bitset<10>(S));
                        // DEBUG(i);
                        // DEBUG(bitset<10>(T));
                        // DEBUG(j);
                        // cerr << endl;

                        if (S & T) continue;
                        if (T & 1<<i and S & 1<<j) {
                            safe = false;
                            // DEBUG("UNSAFE");
                            break;
                        }
                        if (S & 1<<j) dp[S | T][i] = 1;
                        if (T & 1<<i) dp[S | T][j] = 1;
                    }
                }
            }
        }

        cout << (safe ? "SAFE" : "UNSAFE") << endl;
    }

}



Measured memory_bytes: 3312