import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String Sbefore = sc.next(); int N = sc.nextInt(); String Safter = sc.next(); String ans = judge(Sbefore, Safter, N); System.out.println(ans); } static String judge(String x, String y, int N){ String ans = "SUCCESS"; int a=0; int b=0; for(int i=0; i<3; i++){ if(x.charAt(i)=='o')a++; } for(int i=0; i<3; i++){ if(y.charAt(i)=='o')b++; } if(a==b){ if(N>=2){ ans="FAILURE"; }else if(N==0){ if(x.equals(y)){ ans="FAILURE"; } }else{ char [] c = x.toCharArray(); char [] p = new char [3]; for(int i=0; i<2; i++){ if(i==1)continue; p[i]=c[i]; p[(i+1)%3]=c[(i+2)%3]; p[(i+2)%3]=c[(i+1)%3]; String t = String.valueOf(p); if(t.equals(y)){ ans="FAILURE"; break; } } } } return ans; } }