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 % 4, 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) { char[] c = S.toCharArray(); char swap = c[1]; if (changeSide) { c[1] = c[0]; c[0] = swap; } else { c[1] = c[2]; c[2] = swap; } return new String(c); } }