hackercup / 2013 /round3 /name_the_baby.md
wjomlex's picture
2013 Problems
c623d8c verified
|
raw
history blame
No virus
1.15 kB

Jack is blessed with a baby and he and his wife want to name their child. Jack is a mathematician and his wife is very superstitious. She wants the baby's name to contain at least one of her ancestors names as a substring. They have decided that the baby's name should be exactly L characters long, and will only consist of lowercase characters. Jack's wife gives Jack a list of N strings, the names of her ancestors. Jack finds all the name possible names for his baby and lists them in alphabetical order. He asks you to choose the Kth (1-based) name in the list as the name for his child.

Input

The first line contains T, the number of test cases. Each test case begins with the value of L followed by a single integer K. The next line contains a single integer N followed by N lines, each containing the name of one of the wife's ancestors.

Output

For every test case output the name for the child. If no such name exists print "unnamed baby :(".

Constraints

1 ≤ T ≤ 20
1 ≤ L ≤ 100
1 ≤ N ≤ 100
1 ≤ length of each string in the list ≤ 100
1 ≤ K ≤ 1018