sb = input() n = int(input()) % 3 sa = input() S = set(sb) while n: Ns = set() for s in S: Ns.add(s[1]+s[0]+s[2]) Ns.add(s[0]+s[2]+s[1]) S = Ns n -= 1 print("Failure" if sa in S else "Success")