#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int main(){ string SB, SA; int N; cin >> SB; cin >> N; cin >> SA; map memo; string str(3,'x'); if(N == 0){ memo[SB] = 1; } else if(N == 1){ str[0] = SB[1]; str[1] = SB[0]; str[2] = SB[2]; memo[str] = 1; str[0] = SB[0]; str[1] = SB[2]; str[2] = SB[1]; memo[str] = 1; } else if(N%2==0){ memo[SB] = 1; str[0] = SB[2]; str[1] = SB[0]; str[2] = SB[1]; memo[str] = 1; str[0] = SB[1]; str[1] = SB[2]; str[2] = SB[0]; memo[str] = 1; } else { str[0] = SB[0]; str[1] = SB[2]; str[2] = SB[1]; memo[str] = 1; str[0] = SB[1]; str[1] = SB[0]; str[2] = SB[2]; memo[str] = 1; str[0] = SB[2]; str[1] = SB[1]; str[2] = SB[0]; memo[str] = 1; } if(memo.count(SA) > 0) cout << "FAILURE" << endl; else cout << "SUCCESS" << endl; return 0; }