#C3865. Warehouse Stack Operations

    ID: 47339 Type: Default 1000ms 256MiB

Warehouse Stack Operations

Warehouse Stack Operations

You are given a warehouse consisting of m stacks (numbered from 0 to m-1). Your task is to process a series of q operations on these stacks. There are three types of operations:

  • Push Operation: Format 0 s x. Push the integer x onto stack s.
  • Pop Operation: Format 1 s. Pop the top element from stack s if the stack is not empty.
  • Peek Operation: Format 2 s. Output the top element of stack s. If the stack is empty, output "empty".

Your program should output the result of each peek operation in the exact order they appear in the input.

Note: The stacks are zero-indexed.

inputFormat

The input is provided via standard input (stdin) and is formatted as follows:

  • The first line contains two integers m and q separated by a space — the number of stacks and the number of operations respectively.
  • The next q lines each contain a query in one of the following formats:
    • 0 s x for a push operation (push x onto stack s).
    • 1 s for a pop operation (pop the top element from stack s).
    • 2 s for a peek operation (print the top element of stack s, or "empty" if the stack is empty).

outputFormat

For each peek operation (query of the form 2 s), output the result on a new line. If the stack is empty, output the string empty.

## sample
3 10
0 0 5
0 1 10
0 2 15
2 0
2 1
2 2
1 1
2 1
1 0
2 0
5

10 15 empty empty

</p>