S1 = input() N = int(input()) S2 = input() def prt(x): if x == 0: print("FAILURE") else: print("SUCCESS") exit() if S1.count("o") != S2.count("o"): prt(1) if S1.count("o") == 0 and S2.count("o") == 0: prt(0) if S1.count("x") == 0 and S2.count("x") == 0: prt(0) if N == 0: if S1 == S2: prt(0) else: prt(1) X1 = int(S1.replace("x","0").replace("o","1"),2) X2 = int(S2.replace("x","0").replace("o","1"),2) if X1 in [3,5,6]: X1 = 7 - X1 X2 = 7 - X2 if N > 1: prt(0) if X1 == 4: X1 = 1 if X2 == 4: X2 = 1 if X1 == X2: prt(1) else: prt(0)