#include using namespace std; const string msg[] = { "FAILURE", "SUCCESS" }; signed main(){ string S1; cin >> S1; int N; cin >> N; string S2; cin >> S2; int ocnt = 0, xcnt = 0; for( int i = 0; i < S1.size(); ++i ) ocnt += S1[ i ] == 'o', xcnt += S1[ i ] == 'x'; for( int i = 0; i < S2.size(); ++i ) ocnt -= S2[ i ] == 'o', xcnt -= S2[ i ] == 'x'; if( ocnt != 0 or xcnt != 0 ) cout << "SUCCESS" << endl, exit( 0 ); if( N == 0 ) cout << msg[ S1 != S2 ] << endl, exit( 0 ); if( N < 3 ){ string t = S1; swap( t[ 0 ], t[ 1 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); } N &= 1; if( N == 1 ){ string t = S1; if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); swap( t[ 1 ], t[ 2 ] ); swap( t[ 0 ], t[ 1 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); t = S1; swap( t[ 0 ], t[ 1 ] ); swap( t[ 1 ], t[ 2 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); } else{ string t = S1; swap( t[ 0 ], t[ 1 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); t = S1; swap( t[ 1 ], t[ 2 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); t = S1; swap( t[ 0 ], t[ 2 ] ); if( t == S2 ) cout << msg[ 1 ] << endl, exit( 0 ); } cout << msg[ 0 ] << endl; return 0; }