import java.io.BufferedReader; import java.io.InputStreamReader; public class No197 { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in)); String SBefore = br.readLine(); int N = Integer.parseInt(br.readLine()); String SAfter = br.readLine(); if (dfs(N, SBefore, SAfter)) { System.out.println("FAILURE"); } else { System.out.println("SUCCESS"); } } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } static boolean dfs(int N, String S, String SAfter) { if (N == 0) { if (S.equals(SAfter)) { return true; }else { return false; } } if (dfs(N - 1, swap(S, true), SAfter)) { return true; } if (dfs(N - 1, swap(S, false), SAfter)) { return true; } return false; } // trueなら左 // falseなら右 static String swap(String S, boolean changeSide) { StringBuilder sb = new StringBuilder(S); String swap = sb.substring(1, 2); sb.deleteCharAt(1); if (changeSide) { sb.insert(0, swap); } else { sb.append(swap); } return sb.toString(); } }