using System; using System.Linq; class Program { static void Main() { string s0 = Console.ReadLine(); int n = int.Parse(Console.ReadLine()); string s1 = Console.ReadLine(); Console.WriteLine(judge(n, s0, s1)); } static string judge(int n, string s0, string s1) { if (n == 0 && s0 != s1) return "SUCCESS"; int cnt0 = s0.ToCharArray().Count(x => x == 'o'); int cnt1 = s1.ToCharArray().Count(x => x == 'o'); if (cnt0 != cnt1) return "SUCCESS"; if (cnt0 == 0 || cnt0 == 3) return "FAILURE"; char only = cnt0 == 1 ? 'o' : 'x'; if (s0[1] == only && s1[1] == only && n == 1) return "SUCCESS"; if (s0[0] == only && s1[2] == only && n == 1) return "SUCCESS"; if (s0[2] == only && s1[0] == only && n == 1) return "SUCCESS"; return "FAILURE"; } }