ABC string - MarisaOJ: Marisa Online Judge

ABC string

Time limit: 1000 ms
Memory limit: 256 MB
Print all strings of length $n$ consisting of three characters `A`, `B`, and `C`, where no two adjacent characters are the same. For example, the string `ABBC` is not valid because it contains two adjacent `B` characters. ### Input - One line containing an integer $n$. ### Output - Print all valid strings satisfying the condition. The order of printing can be arbitrary. ### Constraints - $1 \le n \le 10$. ### Sample Input: ``` 2 ``` Output: ``` AB BA BC CB AC CA ```