#include int sub1(std::string str) { int ret = 0; if( str[0] == 'o' ) ret |= 0x01; if( str[1] == 'o' ) ret |= 0x02; if( str[2] == 'o' ) ret |= 0x04; return ret; } int main() { bool p[8]; std::string str1, str2; std::string str_o; long N; long temp; for(int i = 0; i < 8; ++i) p[i] = false; std::cin >> str1 >> N >> str_o; if( N > 64 ) { N = 64; } str2 = str1; p[sub1(str_o)] = true; if( p[sub1(str1)] ) { std::cout << "FAILURE" << std::endl; return 0; } for(long i = 0; i < N; ++i) { std::swap(str1[0], str1[1]); std::swap(str2[1], str2[2]); std::swap(str1, str2); } temp = sub1(str1); if( p[temp] ) { std::cout << "FAILURE" << std::endl; return 0; } temp = sub1(str2); if( p[temp] ) { std::cout << "FAILURE" << std::endl; return 0; } std::cout << "SUCCESS" << std::endl; return 0; }