from collections import deque S = input() memo = {} memo[S] = 0 Queue = deque() Queue.append((S, 0)) while Queue: x,cnt = Queue.popleft() y = x[1] + x[0] + x[2] if not y in memo: memo[y] = cnt + 1 Queue.append((y, cnt+1)) y = x[0] + x[2] + x[1] if not y in memo: memo[y] = cnt + 1 Queue.append((y, cnt+1)) N = int(input()) T = input() if not T in memo: print('SUCCESS') elif S == T and len(set(S)) == 1: print('FAILURE') elif memo[T] <= N and memo[T] % 2 == N % 2: print('FAILURE') else: print('SUCCESS')