#c22304. Password

Password

Password

Problem Source

CF 126B

Problem Description

You are given a string ss consisting of lowercase letters. Find the longest substring pp such that pp is both a prefix and a suffix of ss, and appears somewhere in ss as a substring that is neither a prefix nor a suffix. If no such substring exists, output Just a legend.

Given a string ss, output a string pp.

Input Format

One line containing a string ss.

Output Format

Output one line containing a string: the answer.

Sample Input 1

fixprefixsuffix

Sample Output 1

fix

Sample Input 2

abcdabc

Sample Output 2

Just a legend

Constraints

For all data, 1≤∣s∣≤1061 \leq |s| \leq 10^6, and the string consists of lowercase letters only.