SB = input() N = int(input()) SA = input() if SB.count("x") != SA.count("x"): print("SUCCESS") exit() if N == 0 and SB != SA: print("SUCCESS") exit() if N == 2: print("FAILURE") exit() if N == 1: if SB != "xxx" and SB !="ooo": if SB[0] == SA[2] or SB[2] == SA[0]: print("SUCCESS") exit() print("FAILURE")