CSES - E4590 2020 3 - Repeating substring
  • Time limit: 1.00 s
  • Memory limit: 512 MB

You are given a string ss with length nn and your task is to find the longest repeating substring. A repeating substring of ss is a substring of ss such that it appears at least twice in ss. The appearances of substrings can overlap.

Input

The first and only line of input contains string ss with nn characters between a-z. All letters are small case.

Output

Output the longest repeating substring.

If there are multiple equally long repeating substrings, you should print the lexicographically smallest such string.

Limits

  • 1n1051 \le n \le 10^5

Example

Input:

abcdabcdabcd

Output:

abcdabcd