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 uni-directed edge from u to v .
The method should return true if there is a cycle else it should return false.
1 <=T<= 100
0 <=u,v<= N-1
0 1 0 0
0 1 1 2 2 3