PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000055. Đầu cơ chênh lệch tỉ giá (Arbitrage)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đầu cơ chênh lệch tỉ giá (Arbitrage)

Arbitrage

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given exchange rates between every pair of distinct currencies, find the minimum number of exchanges in a closed sequence whose product of rates is strictly greater than 1.01. Print a valid sequence of currency indices, starting and ending at the same currency.

Input

First n; then n lines each containing n-1 positive rates in increasing destination index order, omitting i to i.

Output

Print no arbitrage sequence exists if none. Otherwise output a profitable shortest-length closed sequence of 1-based currency indices, space-separated.

Subtasks

  • Subtask 1 (40 points): 2≤n≤5, 0.01≤rij≤102\le n\le 5,\ 0.01\le r_{ij}\le 10. Exchange rates are positive decimal values with at most five digits after the decimal point.
  • Subtask 2 (60 points): 2≤n≤20, 0.01≤rij≤102\le n\le 20,\ 0.01\le r_{ij}\le 10. Exchange rates are positive decimal values with at most five digits after the decimal point.

Examples

Input

3
1.20000 1.00000
0.90000 1.00000
1.00000 1.00000

Output

1 2 1

Explanation

Exchanging 1→2→1 multiplies the amount by 1.2 × 0.9=1.08, greater than 1.01. The two-exchange cycle is shortest.