#K66687. Current Building Occupants

    ID: 32476 Type: Default 1000ms 256MiB

Current Building Occupants

Current Building Occupants

You are given a series of events recording the entrance and exit of persons in a building. Each event is represented by three values: a timestamp, a person's identifier, and the event type (either "enter" or "exit"). Your task is to determine the list of unique persons who are currently inside the building after processing all the events.

Note that a person may enter and exit multiple times. Only those whose net event count (number of enters minus number of exits) is greater than 0 should be considered inside the building. The final list must be sorted in lexicographical (ascending) order.

Input: The first line contains an integer N representing the number of events. The following N lines each contain an event with three space-separated values: the timestamp (integer), the person's ID (string), and the event type (string, either "enter" or "exit").

Output: Print the sorted list of person IDs who are inside the building separated by a single space. If no one is inside, print an empty line.

inputFormat

The input begins with an integer N (0 ≤ N ≤ 10^5) indicating the number of events. The next N lines each contain an event in the format:

timestamp personID eventType

Here, timestamp is an integer, personID is a string without spaces, and eventType is either "enter" or "exit".

outputFormat

Output a single line containing the person IDs currently inside the building, sorted in ascending (lexicographical) order and separated by a single space. If no persons remain, output an empty line.

## sample
4
1 Alice enter
2 Bob enter
3 Alice exit
4 Charlie enter
Bob Charlie