#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<sstream>
using namespace std;
#define Min(x,y) ((x<y)?x:y)
typedef struct word{
	int n;
	char s[25];
}WORD;
WORD x[30][1000];
int comp(const void *p,const void *q){
	WORD *a=(WORD*)p,*b=(WORD*)q;
	if(a->n==b->n)return strcmp(a->s,b->s);
	else return b->n - a->n;
}

int main(){
	int i,j,n,wn[30],a;
	char sen[1030],str[25],k;
	
	while(1){
		scanf("%d\n",&n);
		if(n==0)break;
		memset(wn,0,sizeof(wn));
		while(n--){
			memset(sen,0,sizeof(sen));
			memset(str,0,sizeof(str));
			fgets(sen,1025,stdin);
			//printf("A:%s",sen);
			istringstream ss(sen);
			while(ss>>str){
				//printf("%s\n",str);
				a=str[0]-'a';
				for(i=0;i<wn[a];i++){
					if(strcmp(str,x[a][i].s)==0){
						x[a][i].n++;
						break;
					}
				}
				if(i==wn[a]){
					x[a][wn[a]].n=1;
					strcpy(x[a][wn[a]++].s,str);
					memset(str,0,sizeof(str));
				}
			}
			/*while(sscanf(sen,"%s",str)!='\0'){
				printf("%s\n",str);
				a=str[0]-'a';
				strcpy(x[a][wn[a]++].s,str);
				memset(str,0,sizeof(str));
			}*/
		}
		scanf("%c\n",&k);
		a=k-'a';
		if(wn[a]==0){
			printf("NA\n");
			continue;
		}
		qsort(x[a],wn[a],sizeof(WORD),comp);
		n=Min(5,wn[a]);
		for(i=0;i<n;i++){
			printf("%s%s",x[a][i].s,(i==n-1)?"\n":" ");
		}
	}
	
	return 0;
}