#P5960. Feasible Solution for Difference Constraints

    ID: 19185 Type: Default 1000ms 256MiB

Feasible Solution for Difference Constraints

Feasible Solution for Difference Constraints

You are given a system of m inequalities with n unknowns of the form:

\[ \begin{cases} x_{c_1} - x_{c'_1} \leq y_1, \\ x_{c_2} - x_{c'_2} \leq y_2, \\ \ \vdots \\ x_{c_m} - x_{c'_m} \leq y_m \end{cases} \]

Your task is to find any set of values for the unknowns \(x_1, x_2, \dots, x_n\) that satisfies the system of inequalities.

Note: The indices in the inequalities are 1-indexed. It is guaranteed that the system has at least one solution.

inputFormat

The first line contains two integers \(n\) and \(m\), representing the number of unknowns and the number inequalities, respectively.

Each of the next \(m\) lines contains three integers \(a\), \(b\) and \(y\), which represents the inequality:

\[ x_a - x_b \leq y \]

(Here, \(a\) corresponds to \(c_i\) and \(b\) corresponds to \(c'_i\)).

outputFormat

Output \(n\) integers separated by spaces representing a feasible solution, i.e. values for \(x_1, x_2, \dots, x_n\) which satisfy all the given inequalities.

sample

3 3
1 2 3
2 3 4
1 3 8
0 0 0