import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String before = sc.next(); int N = sc.nextInt(); String after = sc.next(); sc.close(); int bCoins = 0; int aCoins = 0; for (int i = 0; i < 3; i++) { if (before.charAt(i) == 'o') { bCoins++; } if (after.charAt(i) == 'o') { aCoins++; } } if (aCoins == 1) { before = before.replaceAll("o", "1").replaceAll("x", "2"); after = after.replaceAll("o", "1").replaceAll("x", "2"); } else { before = before.replaceAll("o", "2").replaceAll("x", "1"); after = after.replaceAll("o", "2").replaceAll("x", "1"); } if (aCoins != bCoins) { System.out.println("SUCCESS"); return; } if (aCoins == 0 || aCoins == 3) { System.out.println("FAILURE"); return; } if (before.equals("122") || before.equals("221")) { if (before.equals(after)) { System.out.println("FAILURE"); return; } else if (after.equals("212")) { if (N >= 1) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } else { if (N >= 2) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } } else { if (before.equals(after)) { if (N == 1) { System.out.println("SUCCESS"); return; } System.out.println("FAILURE"); return; } else { if (N == 0) { System.out.println("SUCCESS"); return; } System.out.println("FAILURE"); return; } } } }