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

const int m = 10;

bool exist_loop(const vector<vector<int>>& edge, int p, vector<int>& st, vector<vector<int>>& bc, const vector<int>& parbc) {
    if (st[p] == 1) {
        for (int i = 0; i < m; ++i)
            if (parbc[i] > bc[p][i] + 1) return false;

        return true;
    }
    if (st[p] == 2) return false;
    st[p] = 1;
    for (int i = 0; i < m; ++i)
        bc[p][i] = parbc[i] + ((p >> i) & 1);
    for (int e : edge[p])
        if (exist_loop(edge, e, st, bc, bc[p]))
            return true;

    st[p] = 2;
    return false;
}

bool exist_loop(const vector<vector<int>>& edge) {
    int n = edge.size();
    vector<int> st(n);
    for (int i = 0; i < n; ++i) {
        vector<vector<int>> bc(n, vector<int>(m));
        if (exist_loop(edge, i, st, bc, vector<int>(m)))
            return true;
    }
    return false;
}

int main() {
    while (true) {
        int n;
        cin >> n;
        if (!n) return 0;
        string s;
        cin >> s;
        vector<vector<bool>> v(1 << m, vector<bool>(m));
        vector<vector<int>> edge(1 << m);
        vector<int> par(1 << m, -1);
        int st = 0;
        for (char c : s) {
            if (c == 'u') st = 0;
            else {
                int i = c - '0';
                if (st & (1 << i)) goto A;
                v[st][i] = true;
                st |= 1 << i;
            }
        }
        for (int i = 0; i < (1 << m); ++i) {
            int msk = 0;
            for (int j = 0; j < m; ++j)
                if (v[i][j])
                    msk |= 1 << j;

            if (!msk) continue;
            for (int j = 0; j < (1 << m); ++j)
                if (!(i & j) && (j & msk))
                    edge[i].push_back(j);
        }
        if (exist_loop(edge)) goto A;

        cout << "SAFE\n";
        continue;
        A:
        cout << "UNSAFE\n";
    }
}

