#include using namespace std; typedef long long ll; int main() { string sb; cin >> sb; ll n; cin >> n; string sa; cin >> sa; set sets; if (sb == "xxx" || sb == "ooo"||n == 0) { sets.insert(sb); } else if (n == 1) { string sd[2][2] = { {"oxx","xxo"},{"xoo","oox"} }; string sd2[2] = { "xox","oxo" }; for (int i = 0;i < 2;i++) { for (int j = 0;j < 2;j++) { if (sb == sd[i][j]) { sets.insert(sd2[i]); } } } for (int i = 0;i < 2;i++) { if (sb == sd2[i]) { for (int j = 0;j < 2;j++) { sets.insert(sd[i][j]); } } } } else { string sd[2][3] = { { "oxx","xox","xxo" },{ "xoo", "oxo", "oox" } }; for (int i = 0;i < 2;i++) { for (int j = 0;j < 3;j++) { if (sb == sd[i][j]) { for (int k = 0;k < 3;k++) { sets.insert(sd[i][k]); } } } } } cout << ((sets.find(sa) == sets.end()) ? "SUCCESS":"FAILURE") << endl; return 0; }