#include using namespace std; #define LOG(...) fprintf(stderr,__VA_ARGS__) //#define LOG(...) #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define REP(i,n) for(int i=0;i<(int)(n);++i) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) typedef long long ll; typedef unsigned long long ull; typedef vector vb; typedef vector vi; typedef vector vll; typedef vector vvb; typedef vector vvi; typedef vector vvll; typedef pair pii; typedef pair pll; int main() { string sb, sa; int n; cin >> sb >> n >> sa; int ob = 0, xb = 0; int oa = 0, xa = 0; REP(i, 3) { if (sb[i] == 'o') { ob++; } else { xb++; } if (sa[i] == 'o') { oa++; } else { xa++; } } if (ob != oa || xb != xa) { cout << "SUCCESS" << endl; return 0; } int b, a; REP(i, 3) { if (ob < xb) { if (sb[i] == 'o') b = i; if (sa[i] == 'o') a = i; } if (ob > xb) { if (sb[i] == 'x') b = i; if (sa[i] == 'x') a = i; } } cout << (abs(a - b) > n % 3 ? "SUCCESS" : "FAILURE") << endl; }