bef = list(raw_input()) N = input() aft = list(raw_input()) if bef.count(['x']) != aft.count(['x']): print 'SUCCESS' exit() if N == 0: possible = bef elif N == 1: possible = [[bef[1], bef[0], bef[2]], [bef[0], bef[2], bef[1] ]] elif N == 2: possible = [[bef[0], bef[1], bef[2]], [bef[1], bef[2], bef[0]], [bef[2], bef[0], bef[1]]] else: print 'FAILURE' exit() if aft in possible: print 'FAILURE' else: print 'SUCCESS'