Implement a Queue using Linked List.

**Input Format****:**

The first line of the input contains an integer '**T**' denoting the number of test cases. Then T test cases follow.

First line of each test case contains an integer **Q** denoting the number of queries .

A Query **Q** is of 2 Types

**(i)** 1 x (a query of this type means pushing **'x'** into the queue)

**(ii)** 2 (a query of this type means to pop element from queue and print the poped element)

The second line of each test case contains** Q** queries seperated by space.

**Output Format:**

The output for each test case will be space separated integers having **-1** if the queue is empty else the element poped out from the queue .

You are required to complete the two methods **push** which takes one argument an integer **'x'** to be pushed into the quee and **pop** which returns a integer poped out from othe queue.

**Your Task:**

Since this is a **function **problem, you don't need to take inputs. Just **complete **the **provided functions**. The **printing **is done **automatically **by the** driver code**.

**Constraints:**

1 <=** T **<= 100

1 <=** Q** <= 100

1 <= **x** <= 100

**Example:
Input**:

2

5

1 2 1 3 2 1 4 2

4

1 2 2 2 1 3

2 3

2 -1

**Explanation:**

**Testcase1:**

1 2 the quee will be {2}

1 3 the queue will be {2 3}

2 poped element will be 2 the queue will be {3}

1 4 the queue will be {3 4}

2 poped element will be 3

Note:The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Author: Shubham Joshi 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Sulagna | 117 |

RUTVIKHARIPARA | 116 |

janvidavda105190 | 93 |

harshsiddhapura105461 | 93 |

devsinghindra | 80 |

PiyushPandey4 | 614 |

ASWATHAMA | 561 |

akhyasharma01 | 547 |

john_wick | 521 |

jagrit_07 | 443 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4598 |

Login to report an issue on this page.