#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int main() { string s_before, s_after; ll N,o_num_b=0,o_num_a= 0,x_num_a = 0,x_num_b = 0; string ans; cin >> s_before >> N >> s_after; for (int i = 0; i < s_before.size(); i++) { if (s_before[i] == 'o')o_num_b++; else x_num_b++; } for (int i = 0; i < s_after.size(); i++) { if (s_after[i] == 'o')o_num_a++; else x_num_a++; } if (s_before == "ooo" && s_after == "ooo") { ans = "SUCCESS"; } else if ((o_num_b != o_num_a) || (x_num_a != x_num_b)) { ans = "SUCCESS"; } else { char c; if (o_num_b < x_num_b)c = 'o'; else c = 'x'; int s_ind_bef; for (int i = 0; i < s_before.size(); i++) { if (s_before[i] == c)s_ind_bef = i; } int s_ind_aft; for (int i = 0; i < s_after.size(); i++) { if (s_after[i] == c)s_ind_aft = i; } int d = abs(s_ind_bef - s_ind_aft); if (N == 0) { if (s_before == s_after)ans = "FAILURE"; else ans = "SUCCESS"; } else if (N == 1) { if (d == 1 || d== 0) ans = "FAILURE"; else ans = "SUCCESS"; } else { ans = "SUCCESS"; } } cout << ans << endl; return 0; }