package main import ( "bufio" "fmt" "os" "strconv" "strings" ) var sc = bufio.NewScanner(os.Stdin) func main() { sc.Split(bufio.ScanWords) b := nextLine() n := nextInt() a := nextLine() c1, c2 := strings.Count(b, "o"), strings.Count(a, "o") if c1 != c2 { fmt.Println("SUCCESS") return } if n == 0 && b == a { fmt.Println("FAILURE") return } if n == 0 && b != a { fmt.Println("SUCCESS") return } dp := make(map[string]bool) dp[b] = true mod := -1 for i := 0; i < n && i < 6; i++ { next := make(map[string]bool) for k := range dp { next[string([]byte{k[1], k[0], k[2]})] = true next[string([]byte{k[0], k[2], k[1]})] = true } dp = next if dp[a] { mod = (n - i - 1) % 2 break } } if mod == -1 { fmt.Println("SUCCESS") return } if a[1] == a[2] || a[0] == a[1] || b[1] == b[2] || b[0] == b[1] { fmt.Println("FAILURE") return } if mod%2 == 0 { fmt.Println("FAILURE") return } fmt.Println("SUCCESS") } func nextLine() string { sc.Scan() return sc.Text() } func nextInt() int { i, _ := strconv.Atoi(nextLine()) return i } func nextInt64() int64 { i, _ := strconv.ParseInt(nextLine(), 10, 64) return i } func nextUint64() uint64 { i, _ := strconv.ParseUint(nextLine(), 10, 64) return i } func nextFloat() float64 { f, _ := strconv.ParseFloat(nextLine(), 64) return f }