Common Substring
Two strings composed of 0 and 1 are provided. Your task is to identify all substrings that are common to both strings and determine the k-th substring in lexicographical order.
A string S is considered lexicographically smaller than a string T if one of the following conditions is true:
S is a prefix of T.
There exists an index i (within the bounds of both strings' lengths) such that for all indices j less than i, S[j] = T[j], and S[i] is less than T[i].
Input
The input consists of three lines. The first two lines each contain one of the given strings, with a maximum length of 4000 characters. The third line contains a positive integer k, which is guaranteed not to exceed the total number of common substrings of the two strings.
Output
Print the k-th common substring of the two strings in lexicographical order.