K-th path

Find the K-th string in alphabetical order among all strings spelled by down-right paths from the top-left to the bottom-right of a letter grid.

Medium7GreedyDynamic programmingNo attempts yetTime limit2sMemory limit256 MB

Problem

You are given a table with NN rows and MM columns. Each cell holds one lowercase English letter. Consider a path that starts at the top left cell and ends at the bottom right cell, where every move goes either right or down.

Reading the letters of the cells along the path in the order they are visited gives a string. That string is the value of the path.

Sort all possible paths by their values in alphabetical order and find the value of the KK-th path. Paths whose values are equal are counted separately.

Input

The first line contains the number of rows NN and the number of columns MM. (1N,M301 \le N, M \le 30)

Each of the next NN lines contains exactly MM lowercase English letters with no spaces.

The last line contains an integer KK. (1K10181 \le K \le 10^{18})

The input is always such that the KK-th path exists.

Output

Print the value of the KK-th path on the first line.