AT_arc227_c [ARC227C] Follow the Letters
Description
You are given a string $ S $ of length $ N $ consisting of lowercase English letters. Let $ S_i $ denote the $ i $ -th character of $ S $ .
There are $ N $ islands arranged in a circle, numbered island $ 1 $ , island $ 2 $ , $ \ldots $ , island $ N $ in clockwise order. In particular, the island clockwise-adjacent to island $ N $ is island $ 1 $ . The character $ S_i $ is written on island $ i $ . Initially, there is one person on each island.
You can perform the following operation zero or more times.
- Choose one character $ c $ that appears in $ S $ . Every person departs from the island they are currently on and moves one island at a time in the clockwise direction. Each person stops as soon as they first arrive, after departing, at an island on which the character $ c $ is written. Even if the island a person is currently on has the character $ c $ written on it, that person still departs.
Let $ K $ be the minimum possible number of islands that have one or more people on them after all operations are finished.
Find $ K $ , and a sequence of operations that makes the number of islands with one or more people equal to $ K $ after the operations.
Under the constraints of this problem, it can be proved that there always exists a sequence of operations of length at most $ 10^6 $ that makes the number of islands with one or more people equal to $ K $ .
Input Format
The input is given from Standard Input in the following format:
> $ N $ $ S $
Output Format
Let $ L $ be an integer representing the number of operations, and let $ X $ be a string representing the sequence of operations. Output in the following format:
> $ K $ $ L $ $ X $
If $ L=0 $ , output the third line as an empty line.
$ L $ must satisfy $ 0 \le L \le 10^6 $ .
$ X $ must be a string of length $ L $ consisting of characters that appear in $ S $ , and the $ i $ -th character of $ X $ represents the character chosen in the $ i $ -th operation.
After performing the operations according to the sequence $ X $ , the number of islands with one or more people must be $ K $ .
If multiple outputs satisfy the conditions, you may output any of them.
Explanation/Hint
### Sample Explanation 1
If we perform the operation choosing the character `b`, everyone gathers on the island on which the character `b` is written. The number of islands with people becomes $ 1 $ , and this is the minimum.
### Sample Explanation 2
By choosing `a` first and then `b`, everyone gathers on the same island. The number of islands with people becomes $ 1 $ , and this is the minimum.
### Sample Explanation 3
No matter which operation is performed, each person moves to the next island in the clockwise direction. Therefore, the number of islands with people is always $ 4 $ , so $ K=4 $ . In this sample output, no operation is performed.
### Constraints
- $ 1 \le N \le 1000 $
- $ S $ is a string of length $ N $ consisting of lowercase English letters.
- $ N $ is an integer.