Given a linked list, remove the loop in it if present. The task is to complete the function **removeTheLoop **which takes only one argument the head of the linked list . The function removes the loop in the linked list if present.

**Input:**

The first line of input will contain an integer T denoting the no of test cases . Then T test cases follow. Each test case contains 3 lines . The first line of each test case contains an integer N denoting the no of nodes of the linked list . In the next line are N space separated values denoting the values of the linked list. The next line after it contains an integer x denoting that the last node of the linked list pointing to the xth node thus resulting in cycle.

**Output:**

Your task is to remove the cycle if present output for each test case will be 1 if the loop is successfully removed from the linked list else 0.

**Constraints:**

1<=T<=50

1<=N<=300

**Example(To be used only for expected output) :**

**Input:**

2

3

1 3 4

2

4

1 8 3 4

0

**Output:**

1

1

**Explanation:**

In the first test case N = 3

The linked list with nodes N = 3 is given. here x=2 which means last node is connected with xth node of linked list. Therefore, there exists a loop.

In the second test where N = 4 and x = 0, which means lastNode->next = NULL, thus the Linked list does not contains any loop.

**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

tweyes | 69 |

JulienDELSUC | 50 |

Praveen Shankar Thooyavan | 36 |

SachinTiwari | 34 |

RezaSar | 32 |

dILdAr sK | 641 |

surbhi_7 | 552 |

ERS | 462 |

trnpandey | 419 |

Diprotiv Sarkar | 349 |

akhayrutdinov | 4495 |

sanjay05 | 3633 |

Ibrahim Nash | 3568 |

Quandray | 3144 |

wmlam | 2399 |