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(); // コインの枚数を数える int bCoin = 0; int aCoin = 0; for (int i = 0; i < 3; i++) { if (SBefore.substring(i, i + 1).equals("o")) { bCoin++; } if (SAfter.substring(i, i + 1).equals("o")) { aCoin++; } } String str = "FAILURE"; if (aCoin != bCoin) { str = "SUCCESS"; } else { if (N == 0 && !SBefore.equals(SAfter)) { str = "SUCCESS"; } else if (N == 1) { if (!swap(SBefore, true).equals(SAfter) && !swap(SBefore, false).equals(SAfter)) { str = "SUCCESS"; } } } System.out.println(str); } catch (Exception e) { System.err.println("Error:" + e.getMessage()); } } // 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); } }