#c22304. Password
Password
Password
Problem Source
CF 126B
Problem Description
You are given a string consisting of lowercase letters. Find the longest substring such that is both a prefix and a suffix of , and appears somewhere in as a substring that is neither a prefix nor a suffix. If no such substring exists, output Just a legend.
Given a string , output a string .
Input Format
One line containing a string .
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, , and the string consists of lowercase letters only.