We have a matrix of n*n. Entries are only 0 or 1. Now we need to come up with some matching (vertical or horizontal) for 1's such that 2 1's can be matched. No 0's can be converted to 1 or vice versa. Also, a 1 can be matched to only a single 1, in simple words we cannot a single 1 to two or more 1.
We need to print Yes if there's a matching exist such that all 1's are paired or No if not. If Yes, then print all the matching as well. Print any solution if there are multiple matching for a case.
Example-
Input 4
0011
1110
1110
1111
Output Yes
(1,3)(1,4)
(2,1)(3,1)
(2,2)(3,2)
(2,3)(3,3)
(4,1)(4,2)
(4,3)(4,4)
For n<=200. This can be done by Maximum Bipartite Matching. But can't really do it.