#include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, to) for (int x = 0; x < (to); x++) #define REP(x, a, to) for (int x = (a); x < (to); x++) #define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++) using namespace std; typedef long long ll; typedef pair PII; typedef pair PLL; ll N; string s,t; bool is_success(string x, int d) { bool res = true; if (d == 0) { //cout << x << endl; return x != t; } swap(x[0], x[1]); res &= is_success(x, d - 1); swap(x[0], x[1]); swap(x[1], x[2]); res &= is_success(x, d - 1); swap(x[1], x[2]); return res; } int main() { cin >> s; cin >> N; cin >> t; if (is_success(s, N % 6)) { cout << "SUCCESS" << endl; } else { cout << "FAILURE" << endl; } return 0; }