#include #include #include #include using namespace std; typedef long long LL; int main(){ string before, after; int N; cin >> before >> N >> after; int cnt_b = 0, cnt_a = 0; for(int i = 0; i < 3; i++) cnt_b += before[i]=='o'? 1: 0; for(int i = 0; i < 3; i++) cnt_a += after[i]=='o'? 1: 0; if(cnt_a != cnt_b){ cout << "SUCCESS" << endl; return 0; } if(cnt_a == 1){ if(before == after && N == 1 && before[1] == 'o'){ cout << "SUCCESS" << endl; return 0; } int pos_b = 0; int pos_a = 0; for(int i = 0; i < 3; i++){ if(before[i]=='o'){ pos_b = i; break; } } for(int i = 0; i < 3; i++){ if(after[i]=='o'){ pos_a = i; break; } } if(max(pos_a-pos_b, pos_b-pos_a) > N){ cout << "SUCCESS" << endl; }else{ cout << "FAILURE" << endl; } }else if(cnt_a == 2){ if(before == after && N == 1 && before[1] == 'x'){ cout << "SUCCESS" << endl; return 0; } int pos_b = 0; int pos_a = 0; for(int i = 0; i < 3; i++){ if(before[i]=='x'){ pos_b = i; break; } } for(int i = 0; i < 3; i++){ if(after[i]=='x'){ pos_a = i; break; } } if(max(pos_a-pos_b, pos_b-pos_a) > N){ cout << "SUCCESS" << endl; }else{ cout << "FAILURE" << endl; } }else{ cout << "FAILURE" << endl; } return 0; }