AT_abc402_b [ABC402B] Restaurant Queue

Description

Takahashi wants to manage the waiting line in front of the AtCoder Restaurant. Initially, the waiting line is empty. Each person who joins the line holds a meal ticket with the menu number of the dish they will order. Process $ Q $ queries in order. There are two types of queries, given in the following formats: - `1 X`: One person joins the end of the waiting line holding a ticket with menu number $ X $ . - `2`: Takahashi guides the person at the front of the waiting line into the restaurant. Print the menu number on that person’s ticket.

Input Format

The input is given from Standard Input in the following format: > $ Q $ $ \mathrm{query}_1 $ $ \mathrm{query}_2 $ $ \vdots $ $ \mathrm{query}_Q $ Each query has one of the following two formats: > $ 1 $ $ X $ > $ 2 $

Output Format

For each query, print the answer as specified in the problem statement, each on its own line.

Explanation/Hint

### Sample Explanation 1 Initially, the waiting line is empty. - For the first query, a person holding a ticket with menu number $ 3 $ joins the end of the line. The sequence of menu numbers held by people in line from front to back is $ 3 $ . - For the second query, a person holding a ticket with menu number $ 1 $ joins the end of the line. The sequence becomes $ 3,1 $ . - For the third query, a person holding a ticket with menu number $ 15 $ joins the end of the line. The sequence becomes $ 3,1,15 $ . - For the fourth query, guide the person at the front into the restaurant. That person holds menu number $ 3 $ , so print $ 3 $ . The sequence becomes $ 1,15 $ . - For the fifth query, a person holding a ticket with menu number $ 3 $ joins the end of the line. The sequence becomes $ 1,15,3 $ . - For the sixth query, guide the person at the front into the restaurant. That person holds menu number $ 1 $ , so print $ 1 $ . The sequence becomes $ 15,3 $ . ### Sample Explanation 2 Note that there may be no queries of the second type. ### Constraints - $ 1 \leq Q \leq 100 $ - $ 1 \leq X \leq 100 $ - For each query of the second type, there is at least one person in the line before guiding. - All input values are integers.