package pl.codegym.task.task08.task0829;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/*
Aktualizacja oprogramowania
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Lista adresów
HashMap<String, String> adresy = new HashMap<>();
while (true) {
if (reader.readLine().isEmpty()) {
break;
}
adresy.put(reader.readLine(), reader.readLine());
}
String miasto = reader.readLine();
for (Map.Entry<String, String> para : adresy.entrySet()){
if (para.getKey().contains(miasto)) System.out.println(para.getValue());
}
}
}