Searching for a Hamiltonian cycle under Chvátal's conditions#2474

Searching for a Hamiltonian cycle under Chvátal's conditions

1 second
64 megabytes
Easy

Given a graph with vertices that satisfies Chvátal's theorem, your task is to find a Hamiltonian cycle. According to Chvátal's theorem, in the sorted sequence of vertex degrees in ascending order d_k, for any k < \frac{n}{2}, either d_k > k or d_{n-k} \geq n-k holds.

Input

The first line contains an integer (3 \leq N \leq 100), the number of vertices in the graph. The next lines describe the adjacency matrix. Since the matrix is symmetric and the diagonal contains only zeros, the -th line contains i-1 characters: zeros or ones. If the -th character in the -th line is one, there is an edge between vertices and .

Output

Output a permutation of numbers: the sequence of vertex numbers in the Hamiltonian cycle.

Examples

Example 1

Loading
Loading