#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; signed main(){ string s, t; int n; cin >> s >> n >> t; if(n == 0 && s == t){ cout << "FAILURE" << endl; return 0; } map mp; for(int i = 0; i < 1 << 3; i++){ string str; for(int j = 0; j < 3; j++){ if(i >> j & 1) str += 'o'; else str += 'x'; } mp[str] = INF; } function< void(string,int) > rec = [&](string s, int k){ if(k > 0) mp[s] = min(mp[s], k); if(k > 6) return; swap(s[0], s[1]); rec(s, k+1); swap(s[0], s[1]); swap(s[1], s[2]); rec(s, k+1); }; rec(s, 0); if(mp[t] <= n){ cout << "FAILURE" << endl; }else{ cout << "SUCCESS" << endl; } return 0; }