405837: GYM102133 H Plagiarism
Description
Modern computer systems are quite advanced in plagiarism detection. Consider some text p pretending to be original and text o, which has been copied from some source. Text p is considered as a plagiarism of order k if it has several disjoint substrings of length at least k, concatenation of which is a text o. The order of substrings concatenation to text o corresponds to their order in text p.
Since plagiarism from a single source is a well known problem, engineers started development of a system determining plagiarism from multiple sources. At the very first stage of the system design many training texts are required. Therefore, during the first stage they need to generate a text, which is a plagiarism of order k of two given original texts a and b.
InputFirst line contains positive integer k – order of plagiarism for a text, minimal length of which you are required to find.
Second and third lines contain strings a and b – original texts to generate a plagiarism of order k.
All the strings consist of lower case Latin symbols.
The minimal length of plagiarism of order k text for original texts a and b should be printed in a single line.
ExamplesInput2Output
abaaa
babaa
6Input
3Output
abacabadabacaba
bababanana
19