object Main { def rotate(cur : String,n : Int) : Set[String] = { if(n == 0){ return Set[String](cur); }else{ return rotate(cur.substring(0,2).reverse + cur.substring(2),n-1) union rotate(cur.substring(0,1) + cur.substring(1).reverse,n-1); } } def main(args : Array[String]){ val before = readLine() val N = readLine().toInt min 10 val after = readLine() val future = rotate(before,N) val success = !(future contains after) val message = if(success) "SUCCESS" else "FAILURE"; println(message); } }