#C1610. Process Letter Requests

    ID: 44835 Type: Default 1000ms 256MiB

Process Letter Requests

Process Letter Requests

You are given a sequence of requests to process letters. Each request is either to send a letter or to complete one. When a letter is sent, its unique id is recorded. A complete request for a letter id is only valid if that letter was previously sent and has not already been completed.

Your task is to process the requests in the order they are received. If a valid "complete" request is encountered, record the letter id in the completed list. In the end, output the list of completed letter ids in the order they were completed. If no letters have been completed, output "No letters to complete".

More formally, let \(m\) be the number of requests, and let the sequence of requests be given as \((t_1, n_1), (t_2, n_2), \ldots, (t_m, n_m)\) where \(t_i\) is either send or complete and \(n_i\) is a unique integer identifier. Process each request sequentially. A \(complete\) request is valid if the corresponding \(send\) request has been processed earlier and if the letter with that id has not yet been completed.

inputFormat

The input is given via standard input (stdin) in the following format:

  • The first line contains an integer \(m\) representing the number of requests.
  • The next \(m\) lines each contain a request. Each request consists of a string and an integer separated by a space. The string is either send or complete, and the integer is the letter id.

outputFormat

Output the list of completed letter ids in their completion order to standard output (stdout) in one line separated by a single space. If no valid complete operations occurred, output exactly No letters to complete.

## sample
7
send 1
send 2
complete 1
send 3
complete 2
complete 2
send 4
1 2