#include #include #include #include #include #include #include #include #include #define REP(i,n) for(int i=0;i<(n);i++) using namespace std; int leftswap(int n) { int l = n >> 2 & 0b001; int ln = (n >> 1) & 0b001; return (ln << 2) | (l << 1) | (n & 0b001); } int rightswap(int n) { int r = n & 0b001; int rn = (n >> 1) & 0b001; return(n & 0b100) | (r << 1) | rn; } int main() { cin.tie(0); ios::sync_with_stdio(false); string bef, aft; int N; cin >> bef >> N >> aft; int a = 0, b = 0; REP(i,3) { if (bef[i] == 'o') b |= (1 << i); if (aft[i] == 'o') a |= (1 << i); } if (a == 0b111 || a == 0b000) { if (a == b) { cout << "FAILURE\n"; return 0; } else { cout << "SUCCESS\n"; return 0; } } array dp; dp[b] = true; REP(i,N) { array tmp = { false }; REP(j, 0b111) { if (!dp[j]) continue; tmp[leftswap(j)] = true; tmp[rightswap(j)] = true; } copy(tmp.begin(), tmp.end(), dp.begin()); } if (dp[a]) { cout << "FAILURE" << endl; } else { cout << "SUCCESS" << endl; } return 0; }