S0 = input() N = int(input()) S1 = input() C0 = {"o":0,"x":0} C0["o"] = S0.count("o") C0["x"] = S0.count("x") C1 = {"o":0,"x":0} C1["o"] = S1.count("o") C1["x"] = S1.count("x") if C0["o"]!=C1["o"]: print("SUCCESS") elif C0["o"]==3 or C0["x"]==3: print("FAILURE") elif S0==S1: if S0=="oxo" or S0=="xox": if N%2==0: print("FAILURE") else: print("SUCCESS") else: print("FAILURE") else: ind = 0 for i in range(3): if S0[i]==S1[i]: ind = i break if ind==0 or ind==2: if N>=1: print("FAILURE") else: print("SUCCESS") else: if N>=2: print("FAILURE") else: print("SUCCESS")