#include #include #include #include #include #include #include #include #include // require sort next_permutation count __gcd reverse etc. #include // require abs exit atof atoi #include // require scanf printf #include #include // require accumulate #include // require fabs #include #include #include #include // require setw #include // require stringstream #include // require memset #include // require tolower, toupper #include // require freopen #include // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() #define SUCCESS 0 #define FAILURE 1 using namespace std; typedef long long ll; typedef pair P; const string pos[4][3] = { { "xxx", "xxx", "xxx" }, { "xxo", "xox", "oxx" }, { "xoo", "oxo", "oox" }, { "ooo", "ooo", "ooo" } }; const string res[2] = { "SUCCESS", "FAILURE" }; int main() { ios_base::sync_with_stdio(0); // int T; cin >> T; // while (T-- ){ string s_before; cin >> s_before; int N; cin >> N; string s_after; cin >> s_after; int nb = (int)count (ALL (s_before ), 'o' ); int na = (int)count (ALL (s_after ), 'o' ); int ans = -1; if (nb != na ){ ans = SUCCESS; }else{ int ind_before = -1; int ind_after = -1; rep (i, 3 ) if (pos[nb][i] == s_before ) ind_before = i; rep (i, 3 ) if (pos[na][i] == s_after ) ind_after = i; if (na == 0 || na == 3 ){ ans = FAILURE; }else{ // xxo -> xxo xox -> xox oxx -> oxx if (ind_before == ind_after ){ if (ind_before == 0 || ind_before == 2 ){ ans = FAILURE; }else{ // if (ind_before == 1 ) xox if (N == 1 ) ans = SUCCESS; else ans = FAILURE; } // end if }else{ // xxo -> oxx oxx -> xxo if (abs (ind_before - ind_after ) == 2 ){ if (N <= 1 ) ans = SUCCESS; else ans = FAILURE; // xxo -> xox xox -> oxx }else{ // if (abs(ind_before - ind_after ) == 1 ) if (N == 0 ) ans = SUCCESS; else ans = FAILURE; } // end if } // end if } // end if } // end if // cerr << s_before << ' ' << N << ' ' << s_after << endl; cout << res[ans] << endl; // } // end while return 0; }