Hamiltonian cycle in a complete graph#2480

Hamiltonian cycle in a complete graph

1 second
64 megabytes
Medium

Given a graph with vertices, where each vertex has degree at least , your task is to find a Hamiltonian cycle.

Input

The first line contains an integer (3 \leq N \leq 4000) — the number of vertices in the graph.

The next lines contain the adjacency matrix. Since the adjacency matrix is symmetric and the diagonal entries are always zero, the -th line contains i - 1 symbols: zeros and ones. If the -th symbol in the -th line is one, then there is an edge between vertices and .

It is guaranteed that the graph contains a Hamiltonian cycle and the degree of each vertex is at least .

Output

Output a permutation of numbers — the vertices in the order they appear in the Hamiltonian cycle.

Examples

Example 1

Loading
Loading