#include<bits/stdc++.h>
using namespace std;
const int maxn = 1010;
const int maxlen = 10;
int n, k;
string dic[maxn];
bool isbro[maxn] = {false};
string word;
int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        cin >> dic[i];
    }
    cin>>word;
    scanf("%d", &k);
    int len = word.length();
    sort(dic, dic+n);
    string work = word;
    for(int i = 0; i < n; i++)
    {
        if(dic[i] != word && dic[i].length() == len)
        {
            do{
                if(work == dic[i]){
                    isbro[i] = true;
                }
            }while(next_permutation(work.begin(), work.end()));
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; i++)
    {
        if(isbro[i] == true)
        {
            cnt ++;
        }
    }
    cout << cnt <<endl;
    int temp = 0;
    for(int i = 0; i < n; i++)
    {
        if(isbro[i] == true)
        {
            temp ++;
        }
        if(temp == k){
            cout << dic[i];
            return 0;
        }
    }
}