{"raw_statement":[{"iden":"statement","content":"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.\n\n<center>![image](https://espresso.codeforces.com/cfffbacef433da91e2435337c83b8408749e28b9.png)</center>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_.\n\nDustin doesn't know anything about nginx, so he panicked again and his friends asked you to do his task for him."},{"iden":"input","content":"The first line of input contains two integers _n_ and _m_ (1 ≤ _n_, _m_ ≤ 1000).\n\nThe 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.\n\nThe 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."},{"iden":"output","content":"Print _m_ lines, the commands in the configuration file after Dustin did his task."},{"iden":"examples","content":"Input\n\n2 2\nmain 192.168.0.2\nreplica 192.168.0.1\nblock 192.168.0.1;\nproxy 192.168.0.2;\n\nOutput\n\nblock 192.168.0.1; #replica\nproxy 192.168.0.2; #main\n\nInput\n\n3 5\ngoogle 8.8.8.8\ncodeforces 212.193.33.27\nserver 138.197.64.57\nredirect 138.197.64.57;\nblock 8.8.8.8;\ncf 212.193.33.27;\nunblock 8.8.8.8;\ncheck 138.197.64.57;\n\nOutput\n\nredirect 138.197.64.57; #server\nblock 8.8.8.8; #google\ncf 212.193.33.27; #codeforces\nunblock 8.8.8.8; #google\ncheck 138.197.64.57; #server"}],"translated_statement":[{"iden":"statement","content":"由于学生们破坏了电台设施，学校校长惩罚他们完成任务。Dustin 的任务是为学校网站的 nginx 配置文件添加注释。学校共有 #cf_span[n] 台服务器。每台服务器有一个名称和一个 IP 地址（名称不一定唯一，但 IP 地址是唯一的）。Dustin 知道每台服务器的 IP 和名称。为简化问题，我们假设 nginx 命令的形式为 \"_command ip;_\"，其中 _command_ 是仅由英文小写字母组成的字符串，_ip_ 是学校某台服务器的 IP 地址。\n\n每个 IP 地址的形式为 \"_a.b.c.d_\"，其中 #cf_span[a], #cf_span[b], #cf_span[c] 和 #cf_span[d] 是小于等于 #cf_span[255] 的非负整数（无前导零）。Dustin 需要添加注释的 nginx 配置文件包含 #cf_span[m] 条命令。由于没有人会记住服务器的 IP 地址，为了更好地理解配置，Dustin 必须在每行末尾（每个命令后）添加该 IP 对应的服务器名称作为注释。更正式地，如果某行为 \"_command ip;_\"，Dustin 需要将其替换为 \"_command ip; #name_\"，其中 _name_ 是 IP 等于 _ip_ 的服务器的名称。\n\nDustin 对 nginx 一无所知，因此他又慌了，他的朋友们请求你帮他完成这个任务。\n\n输入的第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n, m ≤ 1000]）。\n\n接下来的 #cf_span[n] 行包含服务器的名称和 IP。每行包含一个字符串 _name_（服务器名称）和一个字符串 _ip_（服务器 IP），以空格分隔（#cf_span[1 ≤ |name| ≤ 10]，#cf_span[name] 仅由英文小写字母组成）。保证所有 IP 互不相同。\n\n接下来的 #cf_span[m] 行包含配置文件中的命令。每行形式为 \"_command ip;_\"（#cf_span[1 ≤ |command| ≤ 10]，_command_ 仅由英文小写字母组成）。保证每个 IP 都属于 #cf_span[n] 台学校服务器之一。\n\n请输出 #cf_span[m] 行，即 Dustin 完成任务后的配置文件中的命令。"},{"iden":"input","content":"输入的第一行包含两个整数 #cf_span[n] 和 #cf_span[m]（#cf_span[1 ≤ n, m ≤ 1000]）。接下来的 #cf_span[n] 行包含服务器的名称和 IP。每行包含一个字符串 _name_（服务器名称）和一个字符串 _ip_（服务器 IP），以空格分隔（#cf_span[1 ≤ |name| ≤ 10]，#cf_span[name] 仅由英文小写字母组成）。保证所有 IP 互不相同。接下来的 #cf_span[m] 行包含配置文件中的命令。每行形式为 \"_command ip;_\"（#cf_span[1 ≤ |command| ≤ 10]，_command_ 仅由英文小写字母组成）。保证每个 IP 都属于 #cf_span[n] 台学校服务器之一。"},{"iden":"output","content":"请输出 #cf_span[m] 行，即 Dustin 完成任务后的配置文件中的命令。"},{"iden":"examples","content":"输入\n2 2\nmain 192.168.0.2\nreplica 192.168.0.1\nblock 192.168.0.1;\nproxy 192.168.0.2;\n输出\nblock 192.168.0.1; #replica\nproxy 192.168.0.2; #main\n\n输入\n3 5\ngoogle 8.8.8.8\ncodeforces 212.193.33.27\nserver 138.197.64.57\nredirect 138.197.64.57;\nblock 8.8.8.8;\ncf 212.193.33.27;\nunblock 8.8.8.8;\ncheck 138.197.64.57;\n输出\nredirect 138.197.64.57; #server\nblock 8.8.8.8; #google\ncf 212.193.33.27; #codeforces\nunblock 8.8.8.8; #google\ncheck 138.197.64.57; #server"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n, m \\in \\mathbb{Z} $ with $ 1 \\leq n, m \\leq 1000 $.  \nLet $ S = \\{ ( \\text{name}_i, \\text{ip}_i ) \\mid i \\in \\{1, \\dots, n\\} \\} $ be the set of server mappings, where:  \n- $ \\text{name}_i \\in \\Sigma^* $, $ \\Sigma = \\{a, \\dots, z\\} $, $ 1 \\leq |\\text{name}_i| \\leq 10 $,  \n- $ \\text{ip}_i \\in \\mathcal{I} $, where $ \\mathcal{I} = \\{ a.b.c.d \\mid a,b,c,d \\in \\mathbb{Z},\\ 0 \\leq a,b,c,d \\leq 255,\\ \\text{no leading zeros} \\} $,  \nand all $ \\text{ip}_i $ are distinct.  \n\nLet $ C = \\{ c_j \\mid j \\in \\{1, \\dots, m\\} \\} $ be the set of configuration lines, where each $ c_j = \\text{cmd}_j\\ \\text{ip}_j';\\ $, with:  \n- $ \\text{cmd}_j \\in \\Sigma^* $, $ 1 \\leq |\\text{cmd}_j| \\leq 10 $,  \n- $ \\text{ip}_j' \\in \\{ \\text{ip}_i \\mid i \\in \\{1, \\dots, n\\} \\} $ (i.e., every IP in $ C $ exists in $ S $).\n\n**Constraints**  \n1. All IPs in $ S $ are unique.  \n2. For each $ j \\in \\{1, \\dots, m\\} $, $ \\text{ip}_j' $ appears in $ S $.  \n\n**Objective**  \nFor each $ j \\in \\{1, \\dots, m\\} $, find the unique $ i \\in \\{1, \\dots, n\\} $ such that $ \\text{ip}_j' = \\text{ip}_i $, and output:  \n$$\n\\text{cmd}_j\\ \\text{ip}_j';\\ \\#\\text{name}_i\n$$","simple_statement":null,"has_page_source":false}