#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int N_MAX = 200001, L = 3; int N; bool dp[N_MAX][1 << L]; string be, af; int main(){ cin >> be >> N >> af; if(N > N_MAX) N = (N_MAX - 2) + (N & 1); int aa = 0, bb = 0; rep(i, 3)if(be[i] == 'o')aa |= 1 << i; rep(i, 3)if(af[i] == 'o')bb |= 1 << i; dp[0][aa] = true; rep(i, N)rep(j, 1 << L){ bool val = dp[i][j]; if(!val)continue; vi le(3), ri(3); rep(k, 3)if(j >> k & 1)le[k] = ri[k] = 1; swap(le[0], le[1]); swap(ri[1], ri[2]); for(const vi & state : {le,ri}){ int nj = 0; rep(k, 3)if(state[k])nj |= 1 << k; dp[i + 1][nj] = true; } } if(!dp[N][bb])cout << "SUCCESS" << endl; else cout << "FAILURE" << endl; }