#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; } /* 1 2 3 2 1 3 2 3 1 3 2 1 3 1 2 1 3 2 1 2 3 */ int main() { std::string str1, str2; std::string str_o; long N; std::cin >> str1 >> N >> str_o; N %= 6; if( N % 2 == 0 ) { if( str1 == str_o ) { std::cout << "FAILURE" << std::endl; return 0; } } else { std::swap(str1[0], str1[1]); if( str1 == str_o ) { std::cout << "FAILURE" << std::endl; return 0; } std::swap(str1[0], str1[1]); std::swap(str1[1], str1[2]); if( str1 == str_o ) { std::cout << "FAILURE" << std::endl; return 0; } std::swap(str1[1], str1[2]); } str2 = str1; for(long i = 0; i < N; ++i) { std::swap(str1[0], str1[1]); std::swap(str2[1], str2[2]); std::swap(str1, str2); } if( str1 == str_o ) { std::cout << "FAILURE" << std::endl; return 0; } if( str2 == str_o ) { std::cout << "FAILURE" << std::endl; return 0; } std::cout << "SUCCESS" << std::endl; return 0; }