Busy Beaver's Colorful Walk

시간 제한2초메모리 제한256 MB

요약
타일 경로가 주어질 때, 한 번에 두 칸 이하로만 이동하는 걸음으로는 만들 수 없는 길이 N의 색 수열을 출력한다.
난이도

어려움10점 중 8점

유형
그래프, 그리디, 구현, 완전 탐색
정답자
아직 제출이 없습니다

문제

Busy Beaver is taking a walk on a path of colorful tiles.

The path consists of a line of NN tiles, each colored either red (r), green (g), blue (b), or yellow (y).

Busy Beaver's walk will follow these rules:

  • The walk visits NN tiles, starting from any initial tile.
  • Each move must be to a tile at most two positions away from the current tile (possibly revisiting a previously visited tile, going backwards, or staying at the same tile).

Busy Beaver will record the sequence of tile colors he visits on the walk in order. Busy Beaver is confident that he can recreate any sequence of NN colors on his walk.

Prove him wrong by providing any sequence of NN colors he can't recreate.

It can be shown that an answer always exists.

입력

Each test contains multiple test cases. The first line contains the number of test cases TT (1≤T≤1041 \leq T \leq 10^4). The description of the test cases follows.

The first line of each test case contains an integer NN (3≤N≤30003 \leq N \leq 3000) --- the number of tiles.

The second line of each test case contains a length NN string of characters in ('r', 'g', 'b', 'y'), the ii'th character denoting the color of the ii'th tile.

It is guaranteed that the sum of NN across all test cases is no more than 3⋅1053 \cdot 10^5.

출력

For each test case, output the answer-sequence as a string of characters in ('r', 'g', 'b', 'y').

힌트

In the first test case, yellow never appears, so a sequence of 33 yellows is not possible.

In the second test case, red never appears, so a sequence of 33 reds is not possible.

In the third test case, every red tile is at least 33 positions away from the yellow tile. So, any walk transitioning from a yellow to a red tile is impossible.

예제1

  1. 예제 1

    입력
    3
    3
    rgb
    3
    gby
    7
    rgbybgr
    
    예상 출력
    yyy
    rrr
    yryryry