#include <cstdio>
#include <cstring>
#include <algorithm>
//#define DEBUG
using namespace std;
 
struct WORD
{
    char s[128];
    int num;
};
 
bool cmp(const WORD A, const WORD B)
{
    if (A.num != B.num) return (A.num > B.num);
    return (strcmp(A.s, B.s) < 0);
}
 
int main()
{
    WORD word[2048];
     
    int n;
    while (scanf("%d%*c", &n), n){
        int num = 0;
         
        for (int i = 0; i < n; i++){
            char str_line[2048];
            char str_word[2048];
            fgets(str_line, 2048, stdin);
            int p = 0;
            while (sscanf(&str_line[p], "%s", str_word), str_line[p] != '\0'){
                int j;
                for (j = 0; j < num; j++){
                    if (strcmp(str_word, word[j].s) == 0){
                        word[j].num++;
                        break;
                    }
                }
                if (j == num){
                    strcpy(word[j].s, str_word);
                    word[j].num = 1;
                    num++;
                }
                 
                p += strlen(str_word) + 1;
            }
        }
         
        sort(word, word + num, cmp);
         
        #ifdef DEBUG
        for (int i = 0; i < num; i++){
            printf("%s\n", word[i].s);
        }
        #endif
         
        char k;
        scanf(" %c", &k);
        int f = 0;
        for (int i = 0; i < num && f < 5; i++){
            if (word[i].s[0] == k){
                if (f > 0){
                    printf(" ");
                }
                printf("%s", word[i].s);
                f++;
            }
        }
        if (f == 0){
            printf("NA");
        }
        puts("");
    }
     
    return 0;
}