eolymp
bolt
Try our new interface for solving problems
Problems

Three Bit Computer

Three Bit Computer

The scientists in the Kingdom of Byteland want to develop a new type of computer, namely the Three Bit Computer (TBC). They predict that the new machine will have the power to solve many hard and still unsolved problems. However, there are some technical difficulties that have to be resolved first. You have been asked to assist the scientists in solving one of them. The scientists are now working on the initialization procedure for the computer memory. The current version of TBC has\textbf{ n} bits of memory numbered from \textbf{1} to \textbf{n}. Each bit can have one of three values \textbf{a}, \textbf{b}, \textbf{c} or might be uninitialized. The following memory initialization operations are supported by the computer: \begin{itemize} \item two consecutive uninitialized bits, i.e., the bits numbered \textbf{i }and \textbf{i+1 }for \textbf{1 }≤ \textbf{i }< \textbf{n}, can be set to two different values, \item two consecutive bits, one unitialized and one initialized to value \textbf{x}, can be set to two di erentvalues not equal to\textbf{x}. \end{itemize} For example, the following initialization procedure is possible for \textbf{n = 4}, \textbf{uuuu} → \textbf{uuab} → \textbf{ucbb} → \textbf{babb}, where \textbf{u}denotes an uninitialized bit of memory. \textbf{Task} Write a program that: \begin{itemize} \item reads the values to which the the memory has to be initialized, \item checks if the initialization is possible, \item writes the answer to the output file. \end{itemize} \InputFile The first line of the input file contains a single positive integer \textbf{n} (\textbf{1} ≤ \textbf{n} ≤ \textbf{10}), the number of patterns. The description of the patterns follows. Description of a single pattern consists of two consecutive lines. The first one contains a positive integer \textbf{l_i}, (\textbf{1 }≤ \textbf{l_i} ≤ \textbf{100000}), the length of the \textbf{i}-th pattern (i.e., the size of computer’s memory). The second line contains a sequence of length \textbf{l_i} consisting of letters \textbf{a}, \textbf{b}, \textbf{c} - the pattern itself. \OutputFile The output file should have \textbf{n} lines, one for each pattern. The \textbf{i}-th line should consist of a single word \textbf{YES}, if the initialization is possible, or \textbf{NO }otherwise.
Time limit 1 second
Memory limit 32 MiB
Input example #1
2
4
aaab
4
aabb
Output example #1
YES
NO