import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String line = sc.nextLine();
String[] arr = line.split(" ");
int length = arr.length;
int num = Integer.parseInt(arr[0]);
int index = Integer.parseInt(arr[length - 1]);
String findLetter = arr[length - 2];
ArrayList<String> list = new ArrayList<>();
for (int i = 1; i <= num; i++) {
String s = arr[i];
if (s.length() != findLetter.length()) {
continue;
}
if (s.equals(findLetter)) {
continue;
}
if (!isBrother(s, findLetter)) {
continue;
}
list.add(s);
}
int size = list.size();
System.out.println(size);
if (size >= index) {
Collections.sort(list);
System.out.println(list.get(index - 1));
}
}
sc.close();
}
private static boolean isBrother(String s, String findLetter) {
char[] sChars = s.toCharArray();
char[] fChars = findLetter.toCharArray();
Arrays.sort(sChars);
Arrays.sort(fChars);
return Arrays.equals(sChars, fChars);
}
}