Common Substring (Easy)#5288

Common Substring (Easy)

1 segundo
64 megabytes
Fácil

Given two strings consisting of the characters and , consider all strings that are substrings of both given strings. Find the -th such common substring in lexicographical order.

A string is considered lexicographically smaller than a string if one of the following conditions is satisfied:

Entrada

The input consists of three lines. The first and second lines contain the two given strings, each of length at most . The third line contains a positive integer , which does not exceed the number of common substrings of the two given strings.

Salida

Output the -th common substring of the two strings in lexicographical order.

Ejemplos

Ejemplo 1

Loading
Loading