New update is available. Click here to update.

Last Updated: 16 Mar, 2021

Difficulty: Moderate

```
The first line of input contains an integer ‘T’, denoting the number of test cases. The test cases follow.
The first line of each test case contains two integers ‘N’ and ‘M’, which denotes the number of people in the given set and the number of rows of the matrix ‘DISLIKE’.
The next M lines contain two integers, DISLIKE[i][0] and DISLIKE[i][1], denoting the two people who dislike each other.
```

```
For each test case, print a single line containing 1 if it is possible to split everyone into two groups under the given conditions otherwise print 0.
The output of each test case will be printed in a separate line.
```

```
You do not need to print anything. It has already been taken care of. Just implement the given function.
```

```
1<= T <= 10
1 <= N <= 2000
0 <= M <= 5000
DISLIKE[i].size = 2
1 <= DISLIKE[i][0],DISLIKE[i][1] <=N
DISLIKE[i][0] != DISLIKE[i][1], for any valid i
Where ’T’ is the number of test cases, and N denotes the number of people in the set’, M denotes the size of the given matrix ‘DISLIKE’.
Time Limit: 1 sec.
```

SIMILAR PROBLEMS

Plantation

Posted: 9 Sep, 2022

Difficulty: Moderate

COUNT ISLANDS

Posted: 14 Sep, 2022

Difficulty: Moderate

Capturing Grid

Posted: 14 Sep, 2022

Difficulty: Moderate

Rotting Oranges

Posted: 15 Sep, 2022

Difficulty: Moderate

Distance to a Cycle in Undirected Graph

Posted: 7 Nov, 2022

Difficulty: Moderate

Popular Interview Problems: