#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { string init, goal; int n; cin >> init >> n >> goal; set curr; curr.insert(init); while(--n >= 0){ set next; for(const string& s : curr){ for(int i=0; i<2; ++i){ string t = s; swap(t[i], t[i+1]); next.insert(t); } } if(curr == next) break; curr.swap(next); } if(curr.find(goal) == curr.end()) cout << "SUCCESS" << endl; else cout << "FAILURE" << endl; return 0; }