Radio Station

题意翻译

说Dustin有一个关于维护学校网站的任务——去给网站添加评论。 他的学校有n(1<=n<=1000)台服务器,每台服务器有一个名字和IP。Dustin知道每个服务器的IP和名称。 (名称可能是一样的,但IP是每台不同的) 名称是一个字符串,IP为a.b.c.d(0<=a,b,c,d<=255) 网站有m(范围跟n一样)条命令,每条命令都是由一个小写字母串和某一台服务器的IP地址和一个分号组成。 每条命令都要输出: 命令中的小写字母串 IP地址; #IP地址对应的名称 [输入] n m 网站名 IP 网站名 IP ...(一共n行) 字母串 IP; 字母串 IP; ...(一共m行) [输出] 字母串 IP地址 #IP地址对应的名称 字母串 IP地址 #IP地址对应的名称 ...(一共m行) 感谢@风格雨关 提供的翻译

题目描述

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. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF918B/ad878d2803e8a6ba1a8b3d8d599829e1c536a92a.png)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.

输入输出格式

输入格式


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.

输出格式


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

输入输出样例

输入样例 #1

2 2
main 192.168.0.2
replica 192.168.0.1
block 192.168.0.1;
proxy 192.168.0.2;

输出样例 #1

block 192.168.0.1; #replica
proxy 192.168.0.2; #main

输入样例 #2

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;

输出样例 #2

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