#K51927. Unique Employee IDs

    ID: 29196 Type: Default 1000ms 256MiB

Unique Employee IDs

Unique Employee IDs

You are given a list of employees. Each employee has an ID and works in a department. Your task is to identify the employees who are the only ones working in their respective departments.

In other words, for each department with exactly one employee (i.e. \(\text{count}(\text{department}) = 1\)), output that employee's ID. The order of the output must follow the order of appearance in the input.

inputFormat

The input is read from stdin and has the following format:

  • The first line contains an integer \(n\) representing the number of employees.
  • The next \(n\) lines each contain an integer and a string separated by a space. The integer represents the employee ID, and the string represents the department name.

outputFormat

Print the IDs of the employees who work in a department by themselves, in the order they appear in the input. The IDs must be separated by a single space. If there is no such employee, print an empty line.

## sample
6
1 HR
2 Engineering
3 HR
4 Marketing
5 Engineering
6 Sales
4 6