Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/navbat-buyruqlari

Queue commands

Easy 1000 ms 128 MB 24%
Share

An empty queue and $n$ commands are given. In a queue the first element added comes out first: pop and front work with the element added earliest (and not yet removed). Execute the commands in order.

  • push x — add the integer $x$ (nothing is printed);
  • pop — remove the element and print it;
  • front — print the element without removing it;
  • size — print the number of elements.

If the queue is empty, error is printed instead of pop and front (the queue does not change).

Queue cells in a row; arrows show that adding happens at one end and removing at the other

Input

The first line contains a positive integer $n$. Each of the next $n$ lines contains one command.

Output

For each of the pop, front and size commands, the answer on a separate line: an integer or error.

Note

$1 \le n \le 10^{5}$
$-10^{9} \le x \le 10^{9}$

Examples

Input #1
6
push 5
push 8
front
pop
front
size
Output #1
5
5
8
1
Input #2
3
pop
push 2
size
Output #2
error
1

Sign in to submit a solution

Signing up is free and takes a minute.