using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
class Solution
{
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine()); // Number of elements which make up the association table.
int Q = int.Parse(Console.ReadLine()); // Number Q of file names to be analyzed.
Dictionary<string, string> openWith = new Dictionary<string, string>();
for (int i = 0; i < N; i++)
{
string[] inputs = Console.ReadLine().Split(' ');
string EXT = inputs[0].ToLower(); // file extension
string MT = inputs[1]; // MIME type.
openWith.Add(EXT,MT);
}
for (int i = 0; i < Q; i++)
{
int b=0;
int c;
string[] a;
string FNAME = Console.ReadLine(); // One file name per line.
if (FNAME.Contains(".")){
a = FNAME.Split('.');
c =a.Length;
string d = a[c-1].ToLower();
if(openWith.ContainsKey(d)){
Console.WriteLine(openWith[d]);
}else if(a[c-1] ==null){
Console.WriteLine("UNKNOWN");
}else{
Console.WriteLine("UNKNOWN");
}
}
else{
Console.WriteLine("UNKNOWN");
}
}
}
}
可以判断文件后缀,输出对应的文件类型,大小写兼容