#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=10;

int n;
string s;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		cin>>s;
		s+="0u";
		vi dp(1<<M),b(M);
		dp[0]=1;
		vvi a;
		int I=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='u'){
				if(I!=i){
					string t=s.substr(I,i-I-1);
					int T=t.size();
					vi c(T);
					for(int j=0;j<T;j++){
						c[j]=t[j]-'0';
						b[t[j]-'0']++;
					}
					b[s[i-1]-'0']++;
					a.push_back(c);
				}
				I=i+1;
			}
		}
		b[0]--;
		int sum=0;
		for(int i=0;i<M;i++){
			sum+=b[i];
			if(!b[i]){
				vi c(1);
				c[0]=i;
				a.push_back(c);
			}
		}
		if(!sum){
			cout<<"SAFE"<<endl;
			continue;
		}
		int A=a.size();
		for(int i=0;i<A;i++){
			int S=a[i].size(),bit=0;
			for(int j=0;j<S;j++){
				int v=a[i][j];
				if(bit&1<<v) break;
				bit+=1<<v;
				for(int k=0;k<1<<M;k++) if((k&bit)==bit) dp[k]|=dp[k-bit];
			}
		}
		cout<<(dp[(1<<M)-1]?"UNSAFE":"SAFE")<<endl;
	}
}