eolymp
bolt
Try our new interface for solving problems
Problems

Dividing the graph

Dividing the graph

Divide the set of vertices of the given graph into two nonempty subsets A and B so that the number of edges between vertices of different subsets is minimal.

Input

First line contains the number of vertices n (2n50) in the graph. Each of the next n lines contains n characters. i-th symbol in j-th line equals to "1" if there is an edge between vertices i and j, and "0" otherwise. The adjacency matrix of the graph thus defined is antireflexive (there are zeros on the main diagonal) and symmetric (relative to the main diagonal).

Output

In the first line print the numbers of vertices in the set A, and in the second line print the numbers of the vertices in the set B. The vertex numbers can be output in any order.

Time limit 1 second
Memory limit 128 MiB
Input example #1
4
0111
1001
1001
1110
Output example #1
2
1 3 4