A = gets.chomp; N = gets.to_i; B = gets.chomp if A.count('o') != B.count('o') puts :SUCCESS elsif N == 0 && A != B puts :SUCCESS elsif N >= 2 puts :FAILURE else puts ("#{A[0]}#{A[2]}#{A[1]}" == B || "#{A[1]}#{A[0]}#{A[2]}" == B) ? :FAILURE : :SUCCESS end