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

#FW0000071. Khôi phục cạnh từ khoảng cách (Antifloyd)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Khôi phục cạnh từ khoảng cách (Antifloyd)

Antifloyd

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Given all-pairs shortest distances of an undirected graph with positive integer edge weights, reconstruct a graph using the fewest edges, or print Need better measurements. if the measurements are inconsistent.

Input

First nn. For i=2,…,ni=2,\dots,n, row ii contains i−1i-1 positive distances Ai1,…,Ai,i−1A_{i1},\ldots,A_{i,i-1}.

Output

If inconsistent, print Need better measurements.. Otherwise print the edge count followed by lines u v w, with u<vu<v in lexicographic order.

Subtasks

  • Subtask 1 (40 points): 2≤n≤62\le n\le 6. Aii=0A_{ii}=0, Aij=Aji>0A_{ij}=A_{ji}>0 với i≠ji\ne j, Aij≤106A_{ij}\le10^6.

  • Subtask 2 (60 points): 2≤n≤302\le n\le 30. Aii=0A_{ii}=0, Aij=Aji>0A_{ij}=A_{ji}>0 với i≠ji\ne j, Aij≤106A_{ij}\le10^6.

Examples

Input

3
2
5 3

Output

2
1 2 2
2 3 3

Explanation

The measured distances are 2, 5, and 3. The distance between 1 and 3 is realized via vertex 2, so only edges 1–2 and 2–3 are needed.