**Compilation/Execution Result:**

Given a directed graph your task is to complete the method isCycle to detect if there is a cycle in the graph or not. You should not read any input from stdin/console.

There are multiple test cases. For each test case, this method will be called individually.

**Input (only to be used for Expected Output):**

The first line of the input contains an integer **'T'** denoting the number of test cases. Then **'T'** test cases follow. Each test case consists of two lines.

Description of test cases is as follows:

The First line of each test case contains two integers **'N' and 'M' ** which denotes the no of vertices and no of edges respectively.

The Second line of each test case contains **'M' ** space separated pairs **u** and **v** denoting that there is an unidirected edge from **u** to **v** .

**Output:**

The method should return true if there is a cycle else it should return false.

**Constraints:**

1 <=T<= 100

1<=N,M<=100

0 <=u,v<= N-1

**Example:
Input:**

2

2 2

0 1 0 0

4 3

0 1 1 2 2 3

1

0

In above first test case there is a graph with 2 vertices and 2 edges the first edge is from 0 to 1 and other edge is from 0 to 0 .

In the second test case there is a graph with 3 vertices and 3 edges from 0 to 1 , 1 to 2 and 2 to 3

Author: Shubham Joshi 1

Rajat Thakur 2 | 195 |

surbhi_7 | 185 |

Ibrahim Nash | 183 |

Anupam Prakash 1 | 167 |

jon_snow_zinda_hai | 159 |

Ibrahim Nash | 697 |

ashrepos | 566 |

shi143din | 427 |

RealHorror | 423 |

shaktiman_shaktiman_shaktiman | 363 |

akhayrutdinov | 4055 |

sanjay05 | 3445 |

Quandray | 2460 |

Michael Riegger | 2232 |

Jasleen Kaur 2 | 2012 |