while True:
try:
str_input = input()
each_list = str_input.split()[1:-2]
word = str_input.split()[-2]
index = int(str_input.split()[-1])
brother_list = []
count = 0
for each in each_list:
if len(each) == len(word) and each != word:
for i in range(len(word)):
if word.count(word[i]) != each.count(word[i]):
break
else:
count += 1
brother_list.append(each)
else:
continue
brother_list.sort()
print(count)
print(brother_list[index -1])
except:
break
try:
str_input = input()
each_list = str_input.split()[1:-2]
word = str_input.split()[-2]
index = int(str_input.split()[-1])
brother_list = []
count = 0
for each in each_list:
if len(each) == len(word) and each != word:
for i in range(len(word)):
if word.count(word[i]) != each.count(word[i]):
break
else:
count += 1
brother_list.append(each)
else:
continue
brother_list.sort()
print(count)
print(brother_list[index -1])
except:
break