cho.sh
Notes
Loading...

Base-36 Number

Time limit

2s

Memory limit

128 MB

Problem

A base-36 digit is one of the digits from 0 to 9 or one of the uppercase letters from A to Z. The letters A through Z represent the values 10 through 35, respectively.

You are given N base-36 numbers. Choose K digit symbols among the 36 possible symbols, then replace every occurrence of each chosen symbol in all N numbers with Z. After the replacements, add all N numbers.

Write a program that finds the largest possible sum. Print that maximum sum in base 36.

Input

The first line contains the number of values N. Each of the next N lines contains one base-36 number. N is at most 50, and each number has length at most 50. The last line contains K. K is either 0 or a positive integer not greater than 36.

Output

Print the answer on one line.