def tezina(Sbef, N, Saft): o_bef = Sbef.count('o') o_aft = Saft.count('o') if o_bef != o_aft: return 'SUCCESS' else: if (o_bef == 1) or (o_bef == 2): if N == 1: if (Sbef == Saft) or (Saft == 'xox'): return 'FAILURE' else: return 'SUCCESS' else: return 'FAILURE' elif (o_bef == 0) or (o_bef == 3): return 'FAILURE' def main(): Sbef = input() N = int(input()) Saft = input() print(tezina(Sbef, N, Saft)) if __name__ == '__main__': main()