Painter

아직 제출이 없습니다메모리 제한1024 MB

문제

You have recently started to study how to paint, and in one of the first classes you learned about the three primary colors: RedYellow, and Blue. If you combine these colors, you can produce many more colors. For now, the combinations that you have studied are the following:

  • Red + Yellow = Orange
  • Red + Blue = Purple
  • Yellow + Blue = Green
  • Red + Yellow + Blue = Gray

You still do not understand shades of colors, therefore the proportion and order of each color in the combination does not matter. For example, combining Red and Yellow produces the same result as combining Yellow and Red, as well as the same result as combining RedYellow, and Red again.

To practice your skills, you want to paint a 1-dimensional painting PP of length NN. Your painting consists of NN squares. From left to right, P_iP\_i represents the color of the ithsquare.Initiallyallsquaresare Uncolored,thatis, i-th square. Initially all squares are *Uncolored*, that is, P_i = Uncolored forevery  = *Uncolored* for every 1≤i≤N$.

In a single stroke, you can choose one of the three primary colors and apply it to a sequence of consecutive squares. In other words, you can choose a color cc and two integers ll and rr, such that 1lrN1≤l≤r≤N, and apply color cc to all squares P_jP\_j such that ljrl≤j≤r. If the square being painted is currently Uncolored, then its color will become cc. Otherwise, the color will be a combination of all the colors applied on this square so far and the new color cc, as described in the list above.

In order to save time, you want to use as few strokes as possible. Given the description of the painting that you want to paint, figure out what is the minimum number of strokes required to paint it.

입력

The first line of the input gives the number of test cases, TTTT test cases follow.

Each test case starts with a line containing an integer NN, representing the length of the painting. Then on the next line, there will be a string PP of length NN, representing the painting. The ii-th character represents the color of square P_iP\_i, according to the following list:

  • U = Uncolored
  • R = Red
  • Y = Yellow
  • B = Blue
  • O = Orange
  • P = Purple
  • G = Green
  • A = Gray

출력

For each test case, output one line containing Case #x: y, where xx is the test case number (starting from 1) and yy is the minimum number of strokes required to paint the painting.

제한

  • 1T1001≤T≤100.
  • 1N1051≤N≤10^5.