P4341 [BJWC2010] Alien Contact

Description

After watching the movie "Contact" (超时空接触), Little P was deeply moved and decided to devote himself to the search for extraterrestrial life. Every night, he climbs onto the roof and tries to use his radio to listen for messages from aliens. Although he hears only noise, he still rewrites the received signal into a string of 0s and 1s according to the high and low levels of the noise, and firmly believes that the aliens' message is hidden within. He believes that the message sent by the aliens must repeat within the binary string he received, so he wants to find all substrings of the binary string that appear more than $1$ time. However, the signal string he received is too long, so he hopes you can write a program to help him.

Input Format

The first line contains an integer $N$, the length of the received signal string. The second line contains a binary string of length $N$, representing the received signal string.

Output Format

Output one line for each substring that appears more than $1$ time, containing its number of occurrences. Output the lines in lexicographical order of the corresponding substrings.

Explanation/Hint

For 100% of the testdata, $0 \le N \le 3000$. Translated by ChatGPT 5