As the guys fried the radio station facilities, the school principal gave them tasks as a punishment. Dustin's task was to add comments to nginx configuration for school's website. The school has n servers. Each server has a name and an ip (names aren't necessarily unique, but ips are). Dustin knows the ip and name of each server. For simplicity, we'll assume that an nginx command is of form "command ip;" where command is a string consisting of English lowercase letter only, and ip is the ip of one of school servers.

 [Image] 

Each ip is of form "a.b.c.d" where a, b, c and d are non-negative integers less than or equal to 255 (with no leading zeros). The nginx configuration file Dustin has to add comments to has m commands. Nobody ever memorizes the ips of servers, so to understand the configuration better, Dustin has to comment the name of server that the ip belongs to at the end of each line (after each command). More formally, if a line is "command ip;" Dustin has to replace it with "command ip; #name" where name is the name of the server with ip equal to ip.

Dustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him.


-----Input-----

The first line of input contains two integers n and m (1 ≤ n, m ≤ 1000).

The next n lines contain the names and ips of the servers. Each line contains a string name, name of the server and a string ip, ip of the server, separated by space (1 ≤ |name| ≤ 10, name only consists of English lowercase letters). It is guaranteed that all ip are distinct.

The next m lines contain the commands in the configuration file. Each line is of form "command ip;" (1 ≤ |command| ≤ 10, command only consists of English lowercase letters). It is guaranteed that ip belongs to one of the n school servers.


-----Output-----

Print m lines, the commands in the configuration file after Dustin did his task.


-----Examples-----
Input
2 2
main 192.168.0.2
replica 192.168.0.1
block 192.168.0.1;
proxy 192.168.0.2;

Output
block 192.168.0.1; #replica
proxy 192.168.0.2; #main

Input
3 5
google 8.8.8.8
codeforces 212.193.33.27
server 138.197.64.57
redirect 138.197.64.57;
block 8.8.8.8;
cf 212.193.33.27;
unblock 8.8.8.8;
check 138.197.64.57;

Output
redirect 138.197.64.57; #server
block 8.8.8.8; #google
cf 212.193.33.27; #codeforces
unblock 8.8.8.8; #google
check 138.197.64.57; #server

Difficulty: interview

Starter code:

Solutions:
n, m = map(int, input().split())

a = {}
for i in range(n):
    x, y = input().split()
    a[y] = x
    
for i in range(m):
    x, y = input().split()
    
    print(x, y, "#" + a[y.replace(';', '')])

n, m = map(int, input().split())
d = {}
for i in range(n):
	im, num = input().split()
	d[num] = im
res = []
for j in range(m):
	im, num = input().split()
	res.append(im + ' ' + num + ' #' + d[num[:-1]])
for i in res:
	print(i)

R = lambda type_ = "int": list(map(eval(type_), input().split(' ')))

n, m = R()
d= dict()

for i in range(n):
    a, b = R('str')
    d[b] = a

for i in range(m):
    a, b = R('str')
    print(a + ' ' + b + ' ' + '#' + d[b[:-1]])



n,m = map(int, input().split())
d = {}
for i in range(n):
    s = input()
    s = s.split()
    d[s[1]] = s[0]
ans = []
for i in range(m):
    s = input()
    s = s.split()
    ip = s[1][:-1]
    ans.append('{} #{}'.format(' '.join(s), d[ip]))
for a in ans:
    print(a)

n,m = list(map(int,input().strip().split(' ')))

ips = {}

for _ in range(n):
	name,ip = input().strip().split(' ')
	ips[ip] = name

for _ in range(m):
	line = input().strip().split(' ')
	line[1] = line[1] + ' ' + '#' + ips[line[1][:-1]]
	print(' '.join(line))


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

D = {}
for _ in range(n):
    name,ip = input().split()
    D[ip] = name

for _ in range(m):
    s = input()
    ip = s.split()[1][:-1]
    s += ' #'+D[ip]
    print(s)


def gis():
    return list(map(int, input().strip().split()))


def gi():
    return int(input())


def gss():
    return input().strip().split()


def problem():
    n, m = gis()
    ip = dict()
    for i in range(n):
        name, ips = gss()
        ip[ips] = name
    for i in range(m):
        command, ips = gss()
        print(command, ips, '#{}'.format(ip[ips[:-1]]))


def __starting_point():
    problem()

__starting_point()

n,m=list(map(int,input().split()))
ip={}
for i in range(n):
    a,b=input().split()
    ip[b]=a
for i in range(m):
    a,b=input().split()
    print(a,b+' #'+ip[b[:-1]])


n, m = map(int, input().split())
d = {}
for i in range(n):
    name, ip = input().split()
    d[ip + ';'] = name;
for i in range(m):
    command, ip = input().split()
    print('{} {} #{}'.format(command, ip, d[ip]))

n, m = [int(i) for i in input().split()]
d = dict()
for i in range(n):
	a, b = [i.rstrip() for i in input().split()]
	d[b] = a
#print(d)
for i in range(m):
	a, b = [i.rstrip() for i in input().split()]
	b = b[:-1]
	print(a, " ", b, "; #", d[b], sep="")

n,m=map(int,input().split())
s=dict()
for x in range(n):
    name,ip=input().split()
    s[ip]=name
for y in range(m):
    a,b=input().split()
    c=b[:-1]
    #print(c)
    print(a,b,"#"+s[c])

n, m = list(map(int, input().split()))
ips = dict()
for _ in range(n):
    s = input().strip().split()
    ips[s[1]] = s[0]
for _ in range(m):
    s = input().strip().split()
    s[1] = s[1][:-1]
    print(s[0], s[1]+";", "#"+ips[s[1]])


n, m = list(map(int, input().split()))
d = {}
for i in range(n):
    name, ip = input().split()
    d[ip] = name

for i in range(m):
    comm, ip = input().split()
    name = d[ip[:-1]]
    print(comm+" "+ip+" #"+name)


n,m=map(int,input().split())
d={}
for _ in range(n):
  name,ip=input().split()
  d[ip]=name
for _ in range(m):
  s=input()
  ip=s.split()[-1]
  if ip[-1]==';':
    ip=ip[:-1]
  print(s,"#"+d[ip])

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

server = {}
for i in range(n):
    name, ip = input().split()
    server[ip] = name

for i in range(m):
    cmd, ip = input().split()
    print('%s %s #%s' % (cmd, ip, server[ip[:-1]]))


n, m = map(int, input().split())
d = {}
for i in range(n):
    t = input()
    t = t.split()
    s = t[1]
    d[s] = t[0]
for i in range(m):
    t = input()
    s = t.split()[1][:-1]
    t += ' #' + d[s]
    print(t)

n, m = map(int, input().strip().split(" "))

import collections
s = collections.defaultdict(lambda: "")

for i in range(n):
    server, ip = input().strip().split(" ")
    s[ip] = server

for i in range(m):
    cmd, ip = input().strip().split(" ")
    print(cmd, ip, "#", end="")
    print(s[ip[:-1]])


def main():
  n,m = map(int, input().split())
  nms={}
  for i in range(n):
    nm,ip = input().split()
    nms[ip]=nm
  for j in range(m):
    nm,ip = input().split()
    print('%s %s #%s'%(nm,ip,nms[ip[:-1]]))


def __starting_point():
    main()
__starting_point()

n, m = [int(v) for v in input().split()]

ip2name = {}
for _ in range(n):
    name, ip = input().split()
    ip2name[ip] = name

for _ in range(m):
    cmd, ip = input().split()
    assert ip[-1] == ';'
    ip = ip[:-1]
    print('%s %s; #%s' % (cmd, ip, ip2name[ip]))




def main():
    n, m = list(map(int, input().split()))
    d = dict()
    for i in range(n):
        name, ip = input().split()
        d[ip] = name

    for i in range(m):
        s = input()
        com, ip = s.split()
        ip = ip.strip(';')
        print(s + ' #' + d[ip])


main()
















n,m = list(map(int,input().split()))
g = {}
for i in range(n):
    na,ip = input().split()
    g[ip] = na
for i in range(m):
    a= input()
    c,ip = a.split()
    print(a+' #'+g[ip[:-1]])


n, m = list(map(int, input().split(' ')))
iptable = {}
for i in range(n):
    a,b = input().split(' ')
    iptable[b] = a
for i in range(m):
    a,b = input().split(' ')
    print(a,b,'#'+iptable[b[:-1]])


from pprint import pprint as pp
def GI(): return int(input())
def GIS(): return list(map(int, input().split()))

def main():
  n, m = GIS()

  d = {}
  for i in range(n):
    name, ip = input().split()
    d[ip] = name

  for i in range(m):
    s = input()
    ip = s.split()[1][:-1]
    print('%s #%s' % (s, d[ip]))

main()


a,b = [int(i) for i in input().split()]
dic1 = {}
for _ in range(a):
	n,m = input().split()
	dic1[m] = n
for _ in range(b):
	c,i = input().split()
	print(c+" "+i+" #"+dic1[i[:-1]])