#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

bool compare(const pair<string,int> &a,const pair<string,int> &b){
  if(a.second!=b.second) return a.second>b.second;
  else return a.first<b.first;
}

int main(void){
  int n;
  while(cin>>n,n){
    cin.ignore();
    map<string,int> cnt[26];
    for(int i=0;i<n;++i){
      string s;getline(cin,s);
      stringstream ss;ss<<s;
      while(!ss.eof()){
      	string w;ss>>w;
        ++cnt[w[0]-'a'][w];
      }
    }
    char c;cin>>c;
    vector<pair<string,int> > v;
    for(map<string,int>::iterator it=cnt[c-'a'].begin();it!=cnt[c-'a'].end();++it)
    	v.push_back(make_pair(it->first,it->second));
    sort(v.begin(),v.end(),compare);
    if(v.empty()) cout<<"NA"<<endl;
    for(int i=0;i<5&&i<v.size();++i){
    	cout<<v[i].first;
    	cout<<((i!=v.size()-1&&i!=4)?" ":"\n");
    }
  }
  return 0;
}