#K14161. Book Stacking Operations

    ID: 24074 Type: Default 1000ms 256MiB

Book Stacking Operations

Book Stacking Operations

In this problem, you are given a series of operations that simulate the stacking of books. Each operation is either an ADD X command, where X is a positive integer representing a book's ID, or an UNDO command which removes the top book from the stack (if any exists). The operations follow a Last-In-First-Out (LIFO) order, similar to standard stack operations. Formally, if you denote the stack operations as:

\(\text{ADD}(x):\, stack.push(x)\) and \(\text{UNDO}:\, stack.pop()\)

After processing all the operations, your task is to output the book ID at the top of the stack. If the stack is empty, output No books.

inputFormat

The input is given via standard input and consists of multiple lines. The first line contains an integer n representing the number of operations. The following n lines each contain an operation. Each operation is either in the form ADD X (with X being a positive integer) or UNDO.

outputFormat

Output a single line showing the book ID at the top of the stack after processing all the operations. If the stack is empty, output No books.

## sample
5
ADD 5
ADD 10
UNDO
ADD 7
UNDO
5