Under construction

Still being built. Things may change

What is the most tedious part of running a contest?

Time limit1sMemory limit1024 MB

Summary
Build S by typing single characters or pasting one copied prefix of S, minimizing typed characters first and total actions second.
Level

Medium7 of 10

Topics
Dynamic programming, String matching, String
Solved
No attempts yet

Problem

The editorial does not have much work, but it is very tedious because it has to be done after the contest. This is especially true for MatKor Cup, which takes more than a semester to prepare.

MatKor began in spring 2022 under the name Donguisuhak (Dongu's math class). At that time it only held seminars, and MatKor Cup explained solutions in seminar form without an editorial. After it switched to an open contest, the editorial became extremely tedious work for Dongu.

MatKor Cup editorials are known for coming out very late. Each problem setter writes their editorial late, and Dongu's merging of the editorials is slower still. Now Dongu wants to start writing the editorial, but typing the string SS is too tedious! To minimize typing, Dongu wants to press ctrl + a and ctrl + c once, then keep using ctrl + v.

Dongu starts with an empty string. To write SS, Dongu can perform the following actions.

  • Action 1: Type the character cc after the current string. This adds 1 to the fatigue.
  • Action 2
    • If the string has not been copied yet, copy the entire current string with ctrl + a, ctrl + c.
    • If the string has already been copied, paste the copied string after the current string with ctrl + v.

Dongu wants the fatigue to be as small as possible. If several action sequences reach the minimum fatigue, Dongu wants the fewest actions. Help Dongu find such a sequence.

Input

The first line contains a string SS of lowercase English letters (1≤∣S∣≤1051\le\lvert S\rvert\le 10^5).

Output

The first line prints the minimum fatigue PP and the minimum number of actions NN among sequences with minimum fatigue.

The second line prints a string of NN characters made of PP 1s and N−PN-P 2s. Performing the actions in this order must produce SS. If several strings are possible, print any one of them.

Examples3

  1. Example 1

    Input
    abcde
    
    Expected output
    5 5
    11111
    
  2. Example 2

    Input
    abcabcabcabcab
    
    Expected output
    5 9
    111222211
    
  3. Example 3

    Input
    abcabcabababc
    
    Expected output
    5 10
    1121212221