#include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() #define ALLR(v) (v).rbegin(),(v).rend() #define fi first #define se second #define PB push_back #define EB emplace_back template using PQ = priority_queue; template using QP = priority_queue,greater>; templatevoid debug(const T &v,ll h,ll w){for(ll i=0;ivoid debug(const T &v,ll n){for(ll i=0;ivoid debug(const vector&v){debug(v,v.size());} templatevoid debug(const vector>&v){for(auto &vv:v)debug(vv,vv.size());} templatevoid debug(stack st){while(!st.empty()){cout<void debug(queue st){while(!st.empty()){cout<void debug(deque st){while(!st.empty()){cout<void debug(PQ st){while(!st.empty()){cout<void debug(QP st){while(!st.empty()){cout<void debug(const set&v){for(auto z:v)cout<void debug(const multiset&v){for(auto z:v)cout<void debug(const array &a){for(auto z:a)cout<void debug(const map&v){for(auto z:v)cout<<"["<bool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> s; ll n;cin >> n; string t;cin >> t; auto f=[&](string x)->int{ int res=(x[0]=='o')*4+(x[1]=='o')*2+(x[2]=='o'); return res; }; auto q=[&](int x)->string{ string res=""; REP(i,3) res+=(x&(1<> d(8,vector(8,INF)); REP(i,8) d[i][i]=0; REP(i,8){ string tmp=q(i); swap(tmp[0],tmp[1]); string u=tmp; swap(tmp[0],tmp[1]); swap(tmp[2],tmp[1]); string v=tmp; swap(tmp[2],tmp[1]); d[i][f(u)]=1; d[i][f(v)]=1; } REP(i,8) REP(j,8) REP(k,8) chmin(d[j][k],d[j][i]+d[i][k]); ll dis=d[f(s)][f(t)]; cerr << dis << endl; if(dis<=n&&(dis%2==n%2)) cout << "FAILURE" << endl; else cout << "SUCCESS" << endl; }