Description

Have you ever used file searching tools provided by an operating system? For example, in DOS, if you type "dir *.exe", the OS will list all executable files with extension "exe" in the current directory. These days, you are so mad with the crappy operating system you are using and you decide to write an OS of your own. Of course, you want to implement file searching functionality in your OS.

Input

The input contains several test cases. Consecutive test cases are separated by a blank line. Each test case begins with an integer N (1 <= N < =100), the number of files in the current directory. Then N lines follow, each line has one string consisting of lowercase letters ('a'..'z') and the dot ('.') only, which is the name of a file. Then there is an integer M (1 <= M <= 20), the number of queries. M lines follow, each has one query string consisting of lowercase letters, the dot and the star ('*') character only. Note that the star character is the "universal matching character" which is used to represent zero or numbers of characters that are uncertain. In the beginning, you just want to write a simple version of file searching, so every string contains no more than 64 characters and there is one and only one star character in the query string. Process to the End Of File (EOF).

Output

For each test case, generate one line for the results of each query. Separate file names in the result by a comma (',') and a blank (' ') character. The file names in the result of one query should be listed according to the order they appear in the input. If there is no matching file, output "FILE NOT FOUND" (without the quotation) instead. Separate two consecutive test cases with a blank line, but Do NOT output an extra blank line after the last one.

Sample Input

4
command.com
msdos.sys
io.sys
config.sys
2
com*.com
*.sys

3
a.txt
b.txt
c.txt
1
*.doc


Sample Output

command.com
msdos.sys, io.sys, config.sys

FILE NOT FOUND



1 #include<stdio.h>
2 #include<string.h>
3 int main()
4 {
5 int n,m,i,j,len1,len2,x,y,z;
6 int flag1=0,pos,count;
7 char s1[110][70],s2[110][70];
8 while(scanf("%d",&n)!=EOF)
9 {
10 getchar();
11 for(i=0; i<n; i++)///输入文件名
12 {
13 gets(s1[i]);
14 }
15 scanf("%d",&m);///输入搜索
16 getchar();
17 for(i=0; i<m; i++)
18 {
19 gets(s2[i]);
20 }
21 for(i=0; i<m; i++)
22 {
23 count=0;
24 for(j=0; j<n; j++)
25 {
26 len1=strlen(s1[j]);
27 len2=strlen(s2[i]) ;
28 for(x=0; x<len2; x++)///查找星号标志
29 {
30 if(s2[i][x]=='*')
31 {
32 pos=x;///标记星号
33 break;
34 }
35 }
36 flag1=0;
37 for(y=0; y<pos; y++) ///左边
38 {
39 if(s1[j][y]!=s2[i][y])
40 {
41 flag1=1;
42 break;
43 }
44 }
45 if(flag1)
46 {
47 continue;
48 }
49 for(z=1; z<len2-pos; z++)///右边
50 {
51 if(s1[j][len1-z]!=s2[i][len2-z])
52 {
53 flag1=1;
54 break;
55 }
56 }
57 if(flag1)
58 {
59 continue;
60 }
61 if(flag1==0)
62 {
63 if(count>=1)/// 输出含有逗号的多组结果,学习这种控制方法
64 printf(", %s",s1[j]);
65 else
66 printf("%s",s1[j]);
67 count++;
68 }
69 }
70 if(count==0)
71 printf("FILE NOT FOUND");
72 printf("\n");
73 }
74 printf("\n");
75 }
76 return 0;
77 }