#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<stack>
#include<bitset>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define stop char nyaa;cin>>nyaa;
const ll mod = 1000000007;
typedef pair<int, int> P;

int n;
string s;

void solve() {
	cin >> s;
	vector<int> v(n+1);
	{
		int cur = 0;
		rep(i, n) {
			if (s[i] == 'u') {
				cur = 0;
			}
			else {
				int t = s[i] - '0';
				if (cur&(1 << t)) {
					cout << "UNSAFE" << endl; return;
				}
				cur ^= (1 << t);
			}
			v[i+1] = cur;
		}
	}
	vector<int> a[10];
	rep(i, n) {
		if (s[i] != 'u') {
			int t = s[i] - '0';
			a[t].push_back(v[i]);
		}
	}
	rep(i, 10) {
		sort(a[i].begin(), a[i].end());
		a[i].erase(unique(a[i].begin(), a[i].end()), a[i].end());
	}
	rep(i, 1024) {
		vector<int> c;
		rep(j, 10) {
			if (i&(1 << j))c.push_back(j);
		}
		if (c.size() < 2)continue;
		int ss = 0;
		rep(j, c.size())ss ^= (1 << c[j]);
		bitset<1024> dp=0;
		dp[0] = true;
		rep(j, c.size()) {
			int id = c[j];
			rep(l, 1024) {
				if (!dp[l])continue;
				rep(k, a[id].size()) {
					if (l&a[id][k])continue;
					dp[l + a[id][k]] = true;
					if (((l + a[id][k])&ss) == ss) {
						cout << "UNSAFE" << endl; return;
					}
				}
			}
		}
	}
	cout << "SAFE" << endl; return;
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (cin >> n, n) {
		solve();
	}
	//stop
	return 0;
}
