#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;
int main() {
// int a, b;
// while (cin >> a >> b) { // 注意 while 处理多个 case
// cout << a + b << endl;
// }
int n;
cin >> n;
multiset<string> dict; //用multiset存储字典可以保存相同元素值同时还能按字典序排序
string str;
while (n--) {
cin >> str;
dict.insert(str);
}
// for (auto it = dict.begin(); it != dict.end(); it++) {
// cout << *it << endl;
// }
string bro;
cin >> bro;
string brox = bro; //保存单词x的初值
sort(bro.begin(), bro.end()); //用全排列函数需要初始序列已经排好序
int k;
cin >> k;
int count = 0;
string ans;
do{
if (dict.find(bro) != dict.end() && bro != brox) {
// cout << bro << endl;
count += dict.count(bro);
for (int i = 0; i < dict.count(bro); i++) {
k--;
if (k == 0) break; //找第k个兄弟单词
}
}
if (!k) {
ans = bro;
k--;
}
}while (next_permutation(bro.begin(), bro.end()));
if (!ans.empty()) {
cout << count << endl << ans << endl;
}
else {
cout << count << endl;
}
return 0;
}