QUEUESEQ - IITKESO207PA1Q3

In this problem, you will implement a sequence of queues. This means that each element of the sequence will be a queue. The operations are as follows:

1) Enqueue(a, i): Add element a to the front of queue i.

2) Dequeue(i): Dequeue frm Queue i.

3) Is_Empty(i): True if Queue i is empty, false otherwise.

Note: The queue sequence is 1 indexed.

Input

First line contains t: the number of test cases.

The second line contains two space separated integers: n and q denoting the number of elements in the sequeunce and the number of queries respectively. The next q lines contain the queries.

Each query contains two or three space separated integers. Opcodes are: 1 for Enqueue(a, i), 2 for Dequeue(i) and 3 for Is_Empty(i).

If opcode is 1, the query has two more space separated integers a and i denoting the element to be enqueued and the queue respectively.

If opcode is 2 or 3, the query has another space separated integer denoting the queue on which the operation is to be performed.

Output

Enqueue(a, i) should return a.

Dequeue(i) should return the element dequeued. If the queue is empty, print "Empty" (without quotes)

Is_Empty(i) should return True or False depending on whether or not the queue is empty.

Constraints

1 <= t <= 10
1 <= n <= 100
1 <= q <= 100000
1 <= a <= 10^9

Example

Input:
1
3 5
1 6 2
1 7 3
2 1
2 3
3 1
Output:
6
7
Empty
7
True

Added by:Programming Club, IITK
Date:2018-01-11
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C NCSHARP C++ 4.3.2 CPP CPP14 C99 JULIA PYPY3

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.