#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); string S, T; ll n; cin >> S >> n >> T; if (S[0] == 'x' && S[2] == 'o') { reverse(all(S)); reverse(all(T)); } rep(i, 3) { if (S[i] == 'o') S[i] = 'A'; else S[i] = 'B'; if (T[i] == 'o') T[i] = 'A'; else T[i] = 'B'; } if (n >= 6) sort(all(S)); if (n == 1) next_permutation(all(S)); n++; do { if (S == T) { dunk("FAILURE"); return 0; } n--; if (n == 0) break; } while (next_permutation(all(S))); dunk("SUCCESS"); return 0; }