

'LANGUAGES' = [[1,0,1],[0,0,1],[0,1,0]] and 'FRIENDS' =[[1,3],[2,3]], Ninja can teach the third language to the third user so all friends can communicate with each other. Hence, the answer is 1 in this case.
The first line of the input contains an integer, 'T,’ denoting the number of test cases.
The first line of each test case contains three space-separated integers, 'N', M’, and ‘L’, denoting the number of rows and the number of columns in the array 'Languages', and the number of rows in the array 'Friends' respectively.
The next 'N' lines of each test case contain 'M' space-separated integers denoting the elements of the array 'LANGUAGES'.
The next 'L' lines of each test case contain two space-separated integers denoting the elements of the array ‘FRIENDS’.
For each test case, return a single integer - the minimum number of users Ninja needs to teach.
1 <= T <= 10
1 <= N <= 500
1 <= M <= 500
1 <= L <= 500
1 <= FRIENDS[i][0], FRIENDS[i][1] <= N
FRIENDS[i][0] != FRIENDS[i][1]
LANGUAGES[i][j] can only contain 2 values, i.e, 0 and 1
All tuples in 'FRIENDS' array are unique.
Time limit: 1 sec
To obtain the total number of users Ninja needs to teach, we first need to find the users who cannot communicate with their friends on the social network. Our approach will be to maintain a set and iterate over the array 'FRIENDS', and we will check for every pair of friends whether both of them know a common language using which they can communicate with each other. If both users do not know a common language, then we will insert both users into the set.
After obtaining the users, we will iterate over each language, and for each language, we will find the total number of users Ninja needs to teach if Ninja chooses that particular language. In the end, we will return the minimum number of users that Ninja needs to teach in any particular language. This approach works as Ninja teaches a common language to those users who cannot communicate with their friends.