import sys def input(): return sys.stdin.readline().rstrip('\n') def main(): s = input() n = int(input()) t = input() if (n == 0 and s != t) or s.count('o') != t.count('o'): return 'SUCCESS' if s.count('o') in [0, 3]: return 'FAILURE' targ = 'o' if s.count('o') == 1 else 'x' if n == 1 and (s == t == 'oxo' or s == t == 'xox'): return 'SUCCESS' return 'SUCCESS' if abs(s.find(targ)-t.find(targ)) > n else 'FAILURE' if __name__ == '__main__': ret = main() if ret is not None: print(ret)