Many internet protocols these days include the option of associating a
media type with the content being sent.
The type is usually inferred from the file extension.
You are to write a program that facilitates the lookup of media types for
a number of files.
You will be given a table of media type associations that associate a certain
file extension with a certain media type.
You will then be given a number of file names, and tasked to determine the correct
media type for each file.
A file extension is defined as the part of the file name after the final period.
If a file name has no periods, then it has no extension and the media type cannot
be determined.
If the file extension is not present in the table, then the media type cannot be
determined.
In such cases you will print "unknown" as the media type.
If the file extension does appear in the table (case matters), then print the associated
media type.

-----Input-----
Input begins with 2 integers N and Q on a line.
N is the number of media type associations, and Q is the number of file names.
Following this are N lines, each containing a file extension and a media type, separated by a space.
Finally, Q lines, each containing the name of a file.
N and Q will be no greater than 100 each.
File extensions will consist only of alphanumeric characters, will have length at most 10, and will be distinct.
Media types will have length at most 50, and will contain only alphanumeric characters and punctuation.
File names will consist only of alphanumeric characters and periods and have length at most 50.

-----Output-----
For each of the Q file names, print on a line the media type of the file.
If there is no matching entry, print "unknown" (quotes for clarity).

-----Sample Input-----
5 6
html text/html
htm text/html
png image/png
svg image/svg+xml
txt text/plain
index.html
this.file.has.lots.of.dots.txt
nodotsatall
virus.exe
dont.let.the.png.fool.you
case.matters.TXT

-----Sample Output-----
text/html
text/plain
unknown
unknown
unknown
unknown

Difficulty: interview

Starter code:

Solutions:
# cook your dish here
n,m=list(map(int,input().split()))
a={}
for i in range(n):
 x,y=input().split()
 a[x]=y
for i in range(m):
 c=input().strip()
 if '.' not in c:
  print("unknown")
 else:
  h=c.split('.')[-1]
  if h in a:
   print(a[h])
  else:
   print('unknown')
  
 


# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

n, q = (int(i) for i in input().split())

file_types = {}
for _ in range(n):
 ext, mime = input().split()
 file_types[ext] = mime

for _ in range(q):
 filename = input().strip()

 if "." in filename:
  ext = filename.split(".")[-1]
  try:
   print(file_types[ext])
  except KeyError:
   print("unknown")
 else:
  print("unknown")

n, q = (int(i) for i in input().split())

file_types = {}
for _ in range(n):
 ext, mime = input().split()
 file_types[ext] = mime

for _ in range(q):
 filename = input().strip()
 found = False
 for ext, mime in list(file_types.items()):
  if filename.endswith("." + ext):
   print(mime)
   found = True
   break
 
 if not found:
  print("unknown")

 # if "." in filename:
 #     ext = filename.split(".")[-1]
 #     try:
 #         print(file_types[ext])
 #     except KeyError:
 #         print("unknown")
 # else:
 #     print("unknown")


n,q=map(int,input().split())
l={}
for i in range(n):
 a,b=input().split()
 l[a]=b
for i in range(q):
 s=input().strip()
 if('.' in s):
  s=s.split('.')
  x=s[-1]
  if(x in l):
   print(l[x])
  else:
   print('unknown')
 else:
  print('unknown')

# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

# cook your dish here
n,q=map(int,input().split())
x={}
for _ in range(n):
 a,b=map(str,input().split())
 x[a]=b
for _ in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

# cook your dish here
# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

# cook your dish here
n,q=map(int,input().split())
x={}
for j in range(n):
 a,b=map(str,input().split())
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")

n,q=list(map(int,input().split()))
x={}
for j in range(n):
 a,b=list(map(str,input().split()))
 x[a]=b
for i in range(q):
 h=input().strip()
 if("." in h):
  c=h.split(".")[-1]
  if(c in x):
   print(x[c])
  else:
   print("unknown")
 else:
  print("unknown")
 


x,y=map(int,input().split())
a={}
for i in range(x):
 p,q=input().split()
 a[p]=q
for i in range(y):
 f=input().strip()
 if "." in f:
  print(a.get(f.split(".")[-1],"unknown"))
 else:
  print("unknown")

N, Q = map(int, input().split())
dic = {}
for i in range(N):
 a,b = input().split()
 dic[a] = b
for kk in range(Q):
 a = input().strip()
 ext = ''
 if '.' in a:
  ext = a.split('.')[-1]
  if ext in dic.keys():
   print(dic[ext])
  else:
   print('unknown')
 else:
  print('unknown')

n, q = list(map(int, input().split()))

extensions = {}
for _ in range(n):
 ext_name, ext_type = input().split()
 extensions[ext_name] = ext_type
 
for _ in range(q):
 filename = input().strip()
 
 if '.' in filename:
  ext = filename.split('.')[-1]

  if extensions.get(ext) != None:
   print(extensions[ext])
  else:
   print("unknown")
   
 else:
  print("unknown")

x,y=list(map(int,input().split()))
a={}
for i in range(x):
 p,q=input().split()
 a[p]=q
for i in range(y):
 f=input().strip()
 if "." in f:
  print(a.get(f.split(".")[-1],"unknown"))
 else:
  print("unknown")
 
 



d={}
n,q = list(map(int,input().split()))
for _ in range(n):
 a,b=input().strip().split()
 d[a]=b
for _ in range(q):
 f=input().strip()
 if "." in f:
  print(d.get(f.split(".")[-1],"unknown"))
 else:
  print("unknown")


def __starting_point():
 N, Q = list(map(int, input().strip().split()))

 d = {}
 for _ in range(N):
  a, b = input().strip().split()
  d[a] = b

 for _ in range(Q):
  text = input().strip()
  idx = text.rfind('.')
  if idx >= 0 and text[idx+1:] in d:
   print(d[text[idx+1:]])
  else:
   print("unknown")
__starting_point()

N,Q = map(int,input().split())

types={}

for _ in range(N):
 K,V=input().split()
 types[K]=V

for _ in range(Q):
 fileName = input().strip()
 I = fileName.rfind('.')
 if(I != -1):
  extension = fileName[I+1:]
  if(extension in types.keys()):
   print(types[extension])
  else:
   print('unknown')
 else:
  print('unknown')

n,q=map(int,input().split())
x=dict(input().strip().split() for i in range(n))
for j in range(q):
 a=list(input().strip().split('.'))
 if(len(a)==1):
  print("unknown")
 elif(a[-1] in x):
  print(x[a[-1]])
 else:
  print("unknown")

# cook your dish here
a,b=list(map(int,input().split()))
sample_dict={}
for i in range(a):
 x=input().strip().split()
 sample_dict[x[0]]=x[1]
for i in range(b):
 x=input().strip()
 if len(x.split('.'))==1:
  print('unknown')
 elif x.split('.')[-1] in list(sample_dict.keys()):
  print(sample_dict[x.split('.')[-1]])
 else:
  print('unknown')


n,q=map(int,input().split())
x=dict(input().strip().split() for i in range(n))
for j in range(q):
 a=list(input().strip().split('.'))
 if(len(a)==1):
  print("unknown")
 elif(a[-1] in x):
  print(x[a[-1]])
 else:
  print("unknown")

n,q=map(int,input().split())
x=dict(input().strip().split() for i in range(n))
for j in range(q):
 a=list(input().strip().split('.'))
 if(len(a)==1):
  print("unknown")
 elif(a[-1] in x):
  print(x[a[-1]])
 else:
  print("unknown")

n,q=map(int,input().split())
x=dict(input().strip().split() for i in range(n))
for j in range(q):
 a=list(input().strip().split('.'))
 if(len(a)==1):
  print("unknown")
 elif(a[-1] in x):
  print(x[a[-1]])
 else:
  print("unknown")