404240: GYM101466 E Text Editor
Description
One of the most useful tools nowadays are text editors, their use is so important that the Unique Natural Advanced Language (UNAL) organization has studied many of the benefits working with them.
They are interested specifically in the feature "find", that option looks when a pattern occurs in a text, furthermore, it counts the number of times the pattern occurs in a text. The tool is so well designed that while writing each character of the pattern it updates the number of times that the corresponding prefix of the total pattern appears on the text.
Now the UNAL is working with the editor, finding patterns in some texts, however, they realize that many of the patterns appear just very few times in the corresponding texts, as they really want to see more number of appearances of the patterns in the texts, they put a lower bound on the minimum number of times the pattern should be found in the text and use only prefixes of the original pattern. On the other hand, the UNAL is very picky about language, so they will just use the largest non-empty prefix of the original pattern that fit into the bound.
InputThe first line contains the text A (1 ≤ |A| ≤ 105) The second line contains the original pattern B (1 ≤ |B| ≤ |A|) The third line contains an integer n (1 ≤ n ≤ |A|) - the minimum number of times a pattern should be found on the text.
OutputA single line, with the prefix of the original pattern used by the UNAL, if there is no such prefix then print "IMPOSSIBLE" (without the quotes)
ExamplesInputaaaaaOutput
aaa
4
aaInput
programmingOutput
unal
1
IMPOSSIBLEInput
abracadabraOutput
abra
1
abraInput
Hello World!Output
H W
5
IMPOSSIBLE