#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	char before[4],after[4];
	scanf("%s",before);
	int n;	scanf("%d",&n);
	scanf(" %s",after);
	short bo=0,ao=0;
	for(int i=0;i<3;i++){
		if(before[i]=='o')	bo++;
		if(after[i]=='o')	ao++;
	}
	if(bo!=ao)	printf("SUCCESS\n");
	else{
		if(n==0){
			if(strcmp(before,after)==0)	printf("FAILURE\n");
			else 	printf("SUCCESS\n");
		}
		else if(n==1){
			char be2[4];	sprintf(be2,"%c%c%c",before[0],before[2],before[1]);
			char be3[4];	sprintf(be3,"%c%c%c",before[1],before[0],before[2]);
			before[3]='\0';	after[3]='\0';	be2[3]='\0';	be3[3]='\0';
			if(strcmp(be2,after)==0||strcmp(be3,after)==0)	printf("FAILURE\n");
			else 	printf("SUCCESS\n");
		}
		else 	printf("FAILURE\n");
	}
	return 0;
}