Races
On a certain railway line, there are N stations, numbered consecutively from 1 to N. The distances between some pairs of these stations are known. Your task is to determine the lengths of all segments between neighboring stations or to indicate if it's impossible due to contradictory or insufficient information.
Input
The input begins with two numbers: N, the number of stations (2 ≤ N ≤ 100), and E, the number of station pairs for which distances are provided (0 ≤ E ≤ 10000). This is followed by E triplets of numbers. Each triplet consists of two station numbers (ranging from 1 to N) and the distance between them. These distances are precise, non-negative real numbers with up to 3 decimal places.
Output
If the segment lengths can be uniquely determined, output the number 1 followed by N–1 real numbers. The first number should represent the distance from the 1st station to the 2nd, the second from the 2nd to the 3rd, and so on. Ensure all numbers are displayed with a precision of up to 3 decimal places.
If the information provided is contradictory or insufficient to uniquely determine the segment lengths, output the number 2.