while True:
try:
str1 = input().split()
k = str1[-1]
str2 = str1[1:-2]
str3 = str1[-2]
str4 = []
n1 = 0
for word in str2:
if word == str3:
continue
elif sorted(word) == sorted(str3):
str4.append(word)
n1 += 1
str4 = sorted(str4)
print(n1)
print(str4[int(k)-1])
except:
break
try:
str1 = input().split()
k = str1[-1]
str2 = str1[1:-2]
str3 = str1[-2]
str4 = []
n1 = 0
for word in str2:
if word == str3:
continue
elif sorted(word) == sorted(str3):
str4.append(word)
n1 += 1
str4 = sorted(str4)
print(n1)
print(str4[int(k)-1])
except:
break