QOJ.ac

QOJ

Límite de tiempo: 1.0 s Límite de memoria: 256 MB Puntuación total: 100 Hackeable ✓

#15210. Router

Estadísticas

As we know, a router is a network device that can connect different networks, select data transmission paths, and forward data. Xiao Qin has just learned some knowledge about routers in computer networks and wants to implement a small router himself. Of course, since implementing a complete router is too complex, Xiao Qin has lowered his standards: this small router only needs to query the next-hop address based on the destination address, without needing to handle various complex routing rules. For entries that cannot be queried, the packet is simply discarded.

Formally, given $n$ routing rules, each rule consists of two strings: the destination address and the next-hop address. Then, accept $m$ queries, where each query includes a destination address, and output the corresponding next-hop address for that destination address. If no corresponding rule exists, output NULL.

Input

The first line contains two integers, $n$ ($1 \le n \le 10^4$) and $m$ ($1 \le m \le 10^5$), representing the number of routing rules and the number of queries, respectively.

The next $n$ lines each contain two strings in the format "255.255.255.255", representing the destination address and the next-hop address. There is a space between the strings. The strings contain only digits "0" through "9" and the separator ".", and no other characters.

The next $m$ lines each contain a string in the format "255.255.255.255", representing the destination address to be queried.

Output

$m$ lines, each containing a string in the format "255.255.255.255" or "NULL", representing the next-hop address corresponding to the query.

Examples

Input 1

3 4
160.116.151.74 254.27.124.39
248.122.91.212 39.60.211.50
185.23.1.167 177.138.76.178
185.23.1.167
160.116.151.74
63.182.123.188
248.122.91.212

Output 1

177.138.76.178
254.27.124.39
NULL
39.60.211.50

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.