public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        HashMap<String, String> list = new HashMap<>();
        while (true) {
            String family = reader.readLine(), town= reader.readLine();
            if (town.isEmpty()) break;
            list.put(town, family);
        }
        String houseNumber = reader.readLine();
        for (Map.Entry<String, String> entry : list.entrySet()) {
            if (entry.getKey().equals(houseNumber)) {
                System.out.println(entry.getValue());
            }
        }
    }
}