#include<iostream>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<functional>
#include<cstdlib>

#define _A_ true

using namespace std;

typedef pair<int,string> P;

int main(){
  int n;
  //map<string,int> dic;
  P dic[10000];
  string s[10000];
  int index=0;
  string si;
  char han;
  map<string,int> Map;
  map<string,bool> used;

  /*
  P p[3];
  p[0] = P(2,"ba");
  p[1] = P(2,"a");
  p[2] = P(1,"c");
  sort(p,p+3);
  for(int i=0;i<3;i++){
    cout << p[i].first << " " << p[i].second << endl;
  }
  */

  while(_A_){
    cin >> n;
    if(n == 0)break;
    index = 0;
    int Nc=0;
    for(int i=0;i<10000;i++){
      dic[i].first = -1;
    }
    Map.clear();
    used.clear();
    int temp = 0,word_sum = 0;
    char c;
    for(int i=0;i<10000;i++)s[i].clear();
    while(temp < n){
      cin >> s[word_sum++];
      scanf("%c",&c);
      if(c == '\n')temp++;
      //cout << "c = " << c;
      //cout << "temp =" << temp << endl;
    }
    cin >> han; 

    

    for(int i = 0;i < word_sum;i++){
      if(s[i][0] == han){
	Map[s[i]]++;
      }
    }  

    int index2=0;

    for(int i=0;i< word_sum;i++){
      if(s[i][0] == han && !used[s[i]]){
	dic[index2] = P(Map[s[i]],s[i]);
	index2++;
	Nc++;
	used[s[i]]=true;
      }
    }
    
    sort(dic,dic+index2,greater<P>());
    
    int index3=0;
    int flag = dic[0].first;
    int ccounter=0;
    map<int,string> Nari;
    int point=0;    
    set<string> Answer;
    int Count=0;

    //for(int i=0;i<index2;i++){
    //cout << dic[i].first << " " <<  dic[i].second << endl;
    //}
    //cout << "------------" << endl;


    if(index2 == 0){
      cout << "NA";
    }else{
      for(int i = 0;i <= index2;i++){
	if(flag != dic[i].first ){
	  //cout << "flag = " << flag  << " " << point <<" "<< i << endl;
	  for(int j=point;j<i;j++){
	    Answer.insert(dic[j].second);
	  }	  
	  if(point == i){
	    Answer.insert(dic[point].second);
	  }
	  set<string>::iterator it = Answer.begin();
	  while(it != Answer.end()){
	    cout << *it;
	    it++;
	    Count++;
	    if(Count < 5&& Nc != Count ){
	      cout << " ";
	    }else{break;}
	  }
	  Answer.clear();
	  point = i;
	  flag = dic[i].first;
	}
      }
    
  
    }
    cout << endl;
 
  }
  return 0;
}