eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

There is no place like 127.0.0.1

There is no place like 127.0.0.1

\includegraphics{https://static.e-olymp.com/content/6f/6f253987f0786cbebbfad76a1f209c5ed3d0fc33.jpg} A friend of yours is a bit on a geeky side. Among other things, he likes to replace some common English words with... \textbf{IPv4} addresses?!? Being a good friend you would like to at least remove these literary abominations from his documents. You somehow got hold of his map of words to addresses (or, it turns out, to range of addresses). Now you would like to replace \textbf{IPv4} addresses with the original English words. \textbf{IPv4} address, if you are not familiar with it, is a \textbf{32}-bit unsigned integer usually represented in dot-decimal notation (e.g. \textbf{172.30.12.255} - \textbf{4} \textbf{8}-bit unsigned integers separated by dots). \InputFile First line of the input contains an integer \textbf{T} (\textbf{1} ≤ \textbf{T} ≤ \textbf{50}) - the number of test cases. Each test case consists of two sections - map and text. Map section starts with an integer \textbf{M} (\textbf{1} ≤ \textbf{M} ≤ \textbf{1000}) on the next line, the number of map entries. Each of the next M lines contains an entry that can contain either word followed by an \textbf{IP} address or a word followed by \textbf{2} \textbf{IP }addresses (see sample input). In the first case, only the given address should be replaced with a word. In the second case, any address within the range should be replaced with the given word. If a range is given, the first address will always be less than the second one. There will be no duplicate entries in the map, meaning no word will apear more than once and no address will repeat. There will be no overlapping ranges of addresses either. Text section starts with an integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{1000}) on the next line, the number of lines of text. Each of the next \textbf{T} lines contains at most \textbf{20} words and/or \textbf{IP} addresses separated by single spaces. Words will contain only letters of English alphabet and \textbf{IP} addresses will be valid (consisting only of digits and dots). \OutputFile For each test case and for each line of text, replace all \textbf{IP} addresses for which you have matching words and print the result to the output. If there is no word mapped to an address that appears in the text, just print the address as is.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1
3
home 127.0.0.1
smile 255.255.255.0 255.255.255.255
gate 10.0.0.1
4
There is no place like 127.0.0.1
Hannibal at the 10.0.0.1
Let us put a 255.255.255.89 on that face
I am very very 1.2.3.4
Вихідні дані #1
There is no place like home
Hannibal at the gate
Let us put a smile on that face
I am very very 1.2.3.4
Автор Hichem Zakaria Aichour
Джерело ACM ICPC CCPC 2013