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

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.

Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

saiujwal13083 | 347 |

isiddhisingh | 252 |

Abhishek_Jadhav | 243 |

_uncle_sam_ | 221 |

c_ocoooo | 217 |

saiujwal13083 | 610 |

SumitSingh27 | 466 |

c_ocoooo | 456 |

rathiarpit29 | 379 |

NaveenKumarNakka | 370 |

blackshadows | 5362 |

Ibrahim Nash | 5242 |

akhayrutdinov | 5111 |

mb1973 | 4931 |

Quandray | 4598 |

Login to report an issue on this page.