#include using namespace std; int main(){ string S; cin >> S; int N; cin >> N; set stock; stock.insert(S); for(int i=0;i newStk; for(string x : stock){ string nx = x; swap(nx[0], nx[1]); newStk.insert(nx); nx = x; swap(nx[1], nx[2]); newStk.insert(nx); } if(stock == newStk) break; stock = newStk; } string T; cin >> T; cout << (stock.count(T) != 0 ? "FAILURE" : "SUCCESS") << endl; return 0; }