public static void main(String[] args) throws IOException
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        Map<String, Integer> map = new HashMap<>();
        while (true) {
            try {
            int id = Integer.parseInt(reader.readLine());
            String name = reader.readLine();

            if (name.equals("")) {
                break;
            }
                map.put(name, id);

            }

            catch ( NumberFormatException | IOException e )
            {
                break;
            }
        }



        for (Map.Entry<String, Integer> pair : map.entrySet()) {
            System.out.println(pair.getValue() + " " + pair.getKey());
        }
    }