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.

geetyadav | 82 |

hari32147 | 76 |

AdityaRaj9 | 75 |

yashrana1 | 74 |

giavytrinh98 | 64 |

abducodes | 839 |

harshtyagi36 | 417 |

vamsikrishna55 | 323 |

sandipbhaumik | 321 |

Akhil varma | 314 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.