|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|1 초||32 MB||5||1||1||100.000%|
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 n bits of memory numbered from 1 to n. Each bit can have one of three values a, b, c or might be uninitialized. The following memory initialization operations are supported by the computer:
For example, the following initialization procedure is possible for n = 4, uuuu -> uuab -> ucbb -> babb, where u denotes an uninitialized bit of memory.
Write a program that:
The input can contain several initialization patterns. The first line of the input file contains a single positive integer N, (1 ≤ N ≤ 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 ℓi, (1 ≤ ℓi ≤ 100 000), the length of the i-th pattern (i.e., the size of computer's memory). The second line contains a sequence of length ℓi consisting of letters a, b, c - the pattern itself.
The output file should have N lines, one for each pattern. The i-th line should consist of a single word YES, if the initialization is possible, or NO otherwise.
2 4 aabb 4 aaab