People in the Company

Interview

Time limit1sMemory limit256 MB

Summary
Given access-card records of enter and leave events, list the names of employees who are currently inside the office, sorted in reverse alphabetical order.
Level

Medium4 of 10

Topics
Hash map, Sorting, Implementation
Solved
No attempts yet

Problem

Sanggeun works at Giggle, a global software company. The company's most distinctive feature is its flexible working hours, so employees are not required to be in the office from 9 to 6.

Each employee may arrive whenever they want and leave whenever they want.

Sanggeun has the log from everyone's access-card system. The log records whether a person entered (enter) or left (leave) the company. Given the log, write a program that determines everyone who is currently in the company.

Input

The first line contains nn, the number of access records in the log. (2≤n≤1062 \le n \le 10^6)

Each of the next nn lines contains one access record, in order: a person's name followed by either enter or leave, separated by a space. enter means arriving at work and leave means leaving work.

No two people share a name, and names that differ in letter case are considered different. Each name is a string of at most 5 uppercase and lowercase English letters.

Output

Print the names of the people currently in the company in reverse dictionary order, one per line. If no one is in the company, print nothing.

Examples1

  1. Example 1

    Input
    4
    Baha enter
    Askar enter
    Baha leave
    Artem enter
    
    Expected output
    Askar
    Artem