#include using namespace std; long long f(string s,string t,int N){ queue< pair > Q; map< pair ,int> ok; Q.push({0,s}); ok[{0,s}] = 0; while( Q.size() ){ auto q = Q.front(); Q.pop(); if( q.second == t && q.first == N ){ return ok[q]; } if( q.first > N ) continue; for(int i = 0 ; i < 3 ; i++) for(int j = i+1 ; j < 3 ; j++){ if( j-i > 1 ) continue; string w = q.second; swap(w[i],w[j]); if( !ok.count({q.first+1,w}) ){ ok[{q.first+1,w}] = ok[q] + 1; Q.push({q.first+1,w}); } } } return 1e15; } int main(){ string s,t; int N; cin >> s >> N >> t; if( N % 2 ) N = min(N,11); else N = min(N,10); long long r = f(s,t,N); if( r > N ) { cout << "SUCCESS" << endl; }else{ cout << "FAILURE" << endl; } }