# -*- coding: utf-8 -*- S_before = input() N = int(input()) S_after = input() o_before = o_after = x_before = x_after = 0 for i in range(3): if S_before[i] == 'o': o_before += 1 else: x_before += 1 if S_after[i] == 'o': o_after += 1 else: x_after += 1 if o_before != o_after: print('SUCCESS') elif o_before == o_after and o_before == 3: print('FAILURE') else: # o_beforeとo_after,x_beforeとx_afterはそれぞれ等しく2以下 if o_before < x_before: # コインが1つだけ入っている o_dist = abs(S_before.index('o') - S_after.index('o')) if o_dist == 0: if S_before.index('o') == 0 or S_before.index('o') == 2: print('FAILURE') elif N != 1: print('FAILURE') else: print('SUCCESS') elif o_dist == 1: if N >= 1: print('FAILURE') else: print('SUCCESS') else: if N >= 2: print('FAILURE') else: print('SUCCESS') else: # コインが2つはいっている x_dist = abs(S_before.index('x') - S_after.index('x')) if x_dist == 0: if S_before.index('x') == 0 or S_before.index('x') == 2: print('FAILURE') elif N != 1: print('FAILURE') else: print('SUCCESS') elif x_dist == 1: if N >= 1: print('FAILURE') else: print('SUCCESS') else: if N >= 2: print('FAILURE') else: print('SUCCESS')