시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 1024 MB422100.000%

문제

You are given a string $S$ of length $N$ which consists of digits 0-9. You do the following operations on the string in the order given.

  1. Find all the substrings 01 and replace each of them with 2.
  2. Find all the substrings 12 and replace each of them with 3.
  3. Find all the substrings 23 and replace each of them with 4.
  4. Find all the substrings 34 and replace each of them with 5.

.

.

.

  1. Find all the substrings 89 and replace each of them with 0.
  2. Find all the substrings 90 and replace each of them with 1.

You repeat this process in the same given order until none of the above operations change the string. For example, if $S$ is 12 then we do not stop at operation $1$ since it does not affect the string but perform operation $2$ and change the string to 3. We can see that the string does not change further no matter how many times we repeat the above process.

Your task is to find how the final string will look like for the given $S$.

입력

The first line of the input gives the number of test cases, $T$. $T$ test cases follow. Each test case consists of two lines.

The first line of each test case contains an integer $N$, denoting the length of the string $S$.

The second line of each test case contains a string $S$ of length $N$.

출력

For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the final string obtained.

제한

  • $1≤T≤100$.
  • The input string only consists of digits 0-9.

Test Set 1 (10점)

시간 제한: 20 초

  • $1≤N≤100$

Test Set 2 (16점)

시간 제한: 60 초

For at most 10 cases:

  • $1≤N≤5×10^5$.

For the remaining cases:

  • $1≤N≤100$.

예제 입력 1

4
3
012
4
0145
5
00000
11
98765432101

예제 출력 1

Case #1: 22
Case #2: 26
Case #3: 00000
Case #4: 1

In Sample Case #1, substring 01 is replaced with 2 and the resulting string is 22 which is not affected further by any of the operations. Therefore final string is 22.

In Sample Case #2, substring 01 is replaced with 2 and the resulting string is 245. The substring 45 is replaced with 6 and the resulting string is 26 which is not further affected by any of the operations. Therefore final string is 26.

In Sample Case #3, since the operations cannot be performed on the given string, the string does not change.

In Sample Case #4, all the operations can be performed sequentially on the string and the final string is 1.

채점 및 기타 정보

  • 예제는 채점하지 않는다.