BETA

Difficulty Level:

Easy

Total Submissions: 558 Accuracy:

13.8%

Matrix Game - 1
     

Shivam is a Geek and loves playing with matrix. Given a matrix containing 0’s and 1’s. Group all the row numbers (starting index 0) which are having 1’s at same position. Shivam being lazy wants your help to do the job.

Input:
The first line of input consists of T test cases. Then T test cases follow. The first line of every test case consists of a integer N, denoting number of rows and columns in the matrix. Second line of every test case consists N spaced elements Ai, denoting elements of the matrix (In the form of String).

Output:
For each test case in a single line output for each test case, print all the space separated row indices, if not possible to print then print "-1".

Constraints:
1<=T<=100
1<=N<=20


Example:
Input:

1
4
0010 0100 0010 0000
Output:
0 1

Explanation:

In the above test case, first and third row have the 1's at same column,i.e., 2(starting index from 0) so group first and third row. And print the index of first row, i.e., 0 (starting index from 0).

For second row, as it is the only row with same indexing of 1's so print it's index , i.e., 1

For forth row, 1 is not present in this row so didn't print anything.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.