SB = input() N = int(input()) SA = input() pat = [] if N == 0: pat = [[0, 1, 2]] elif N == 1: pat = [[1, 0, 2], [0, 2, 1]] elif N % 2 == 0: pat = [[0, 1, 2], [1, 2, 0], [2, 0, 1]] else: pat = [[1, 0, 2], [0, 2, 1], [2, 1, 0]] success = True for p in pat: if all(SB[i] == SA[p[i]] for i in range(3)): success = False break print('SUCCESS' if success else 'FAILURE')