#D11382. Queue

    ID: 9465 Type: Default 1000ms 268MiB

Queue

Queue

Queue is a container of elements that are inserted and deleted according to FIFO (First In First Out).

For nn queues QiQ_i (i=0,1,...,n1i = 0, 1, ..., n-1), perform a sequence of the following operations.

  • enqueue(tt, xx): Insert an integer xx to QtQ_t.
  • front(tt): Report the value which should be deleted next from QtQ_t. If QtQ_t is empty, do nothing.
  • dequeue(tt): Delete an element from QtQ_t. If QtQ_t is empty, do nothing.

In the initial state, all queues are empty.

Constraints

  • 1n1,0001 \leq n \leq 1,000
  • 1q200,0001 \leq q \leq 200,000
  • 1,000,000,000x1,000,000,000-1,000,000,000 \leq x \leq 1,000,000,000

Input

The input is given in the following format.

n  qn \; q query1query_1 query2query_2 : queryqquery_q

Each query queryiquery_i is given by

0 tt xx

or

1 tt

or

2 tt

where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively.

Output

For each front operation, print an integer in a line.

Example

Input

3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0

Output

1 4 2

inputFormat

Input

The input is given in the following format.

n  qn \; q query1query_1 query2query_2 : queryqquery_q

Each query queryiquery_i is given by

0 tt xx

or

1 tt

or

2 tt

where the first digits 0, 1 and 2 represent enqueue, front and dequeue operations respectively.

outputFormat

Output

For each front operation, print an integer in a line.

Example

Input

3 9 0 0 1 0 0 2 0 0 3 0 2 4 0 2 5 1 0 1 2 2 0 1 0

Output

1 4 2

样例

3 9
0 0 1
0 0 2
0 0 3
0 2 4
0 2 5
1 0
1 2
2 0
1 0
1

4 2

</p>