The workers of the POP (Prevention of Plagiarism) department in TOFU (Tellers of Fairytales Unlimited) kingdom are tired of spending hours and hours and hours of their time, reading and comparing the stories created by their eldest in search of any traces of "inspiration borrowing", more commonly known as plagiarism.
You are going to help POP workers by building a program that finds any repeated piece of text in any two stories.
The first line contains the first story. The second line contains the second story. These stories only contain alphanumeric characters (no characters with accents or diacritical marks as, for example, á, õ, ç, etc, are allowed), commas, points, and spaces. There can be only one space between words.
The output contains all pieces of consecutive text (with no leading nor trailing spaces) with more than 5 characters, that appear in the two stories. These pieces appear one per line, by descending order of length. If there are more than one piece with the same length, the order will be the same as the one in which they appear in the first story.
Sample Input 1
Once upon a time in the TOFU kingdom, a dwarf had an incredible idea. He thought he would be capable of painting the whole landscape red. Once upon a time in the TOFU land, a goblin had an inconceivable idea. He thought he ould paint the whole landscape blue.
Sample Output 1
Once upon a time in the TOFU ble idea. He thought he the whole landscape had an inc
Sample Input 2
roses are red, violets are blue, sugar is sweet, and so are you. we will buy very pretty things, a-walking through the faubourgs, violets are blue, roses are red, i love my loves.
Sample Output 2
, violets are blue, roses are red