#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int n;
string str, tarStr;
vector<string> vec;
while(cin >> n)
{
while(n--)
{
cin >> str;
vec.push_back(str);
}
cin >> tarStr >> n;
vector<string> rst;
string temp1 = tarStr;
sort(temp1.begin(), temp1.end());
for(auto it = vec.begin(); it != vec.end(); ++it)
{
string temp2 = *it;
sort(temp2.begin(), temp2.end());
if(temp1 == temp2 && *it != tarStr) rst.push_back(*it);
}
sort(rst.begin(), rst.end());
cout << rst.size() << endl;
if(n <= rst.size()) cout << rst[n - 1] << endl;
}
return 0;
}