#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <tuple>
#include <math.h>
#include <iomanip>
#include <string>

using namespace std;

class Sover {
};
int main()
{
	while (true) {
		int n;
		cin >> n;
		if (n == 0)break;

		string s;
		cin >> s;
		set<tuple<int, int>> commands;
		int now = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == 'u') {
				now = 0;
			}
			else {
				int num = s[i] - '0';
				commands.emplace(now, num);
				now += 1 << num;
			}
		}

		set<tuple<int, int>> dp;
		for (tuple<int, int> tpl : commands) {
			dp.emplace(tpl);
		}
		bool can = true;
		for (int i = 0; i < 9; i++) {
			set<tuple<int, int>> next;
			for (tuple<int, int> val : dp) {
				int pat, num;
				tie(pat, num) = val;
				next.emplace(val);
				for (tuple<int, int> tmp : commands) {
					int pat_tmp, num_tmp;
					tie(pat_tmp, num_tmp) = tmp;
					if ((pat ^ pat_tmp) == pat + pat_tmp) {
						if ((((1 << num) & (pat + pat_tmp)) > 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) == 0)) {
							next.emplace(pat + pat_tmp, num_tmp);
						}
						if ((((1 << num) & (pat + pat_tmp)) == 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) > 0)) {
							next.emplace(pat + pat_tmp, num);
						}
						if ((((1 << num) & (pat + pat_tmp)) > 0)
							&& (((1 << num_tmp) & (pat + pat_tmp)) > 0)) {
							can = false;
						}
					}
					if (!can)break;
				}
				if (!can)break;
			}
			dp = next;
			if (!can)break;
		}

		if (can)		cout << "SAFE" << endl;
		else cout << "UNSAFE" << endl;
	}
}
