package yukicoder; import java.util.Arrays; import java.util.Scanner; public class Q1191 { public static void main(String[] args) { new Q1191().solver(); } void solver() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); double[][] matrix = new double[n][n]; for (int i = 0; i < m; i++) { int src = sc.nextInt(); int dst = sc.nextInt(); int rate = sc.nextInt(); matrix[dst][src] = rate; } for (int i = 0; i < n; i++) { double sum = 0; for (int j = 0; j < n; j++) { sum += matrix[j][i]; } for (int j = 0; j < n; j++) { matrix[j][i] /= sum; } } double[][] state = new double[n][1]; for (int i = 0; i < n; i++) { state[i][0] = 10; } // if (n <= 300) { // state = MtPow(100, matrix, state); // } else { for (int i = 0; i < 100; i++) { state = MtPrd(matrix, state); } // } for (int i = 0; i < n; i++) { System.out.printf("%f\n", state[i][0]); // System.out.println(state[i][0]); } } double[][] MtPow(long n, double[][] A, double[][] v) { for (; n > 0; n = n >> 1) { if ((n & 1) == 1) v = MtPrd(A, v); A = MtPrd(A, A); } return v; } double[][] MtPrd(double[][] A, double[][] B) { double[][] C = new double[A.length][B[0].length]; for (int i = 0; i < A.length; i++) { for (int j = 0; j < B[0].length; j++) { for (int k = 0; k < A[0].length; k++) { C[i][j] += A[i][k] * B[k][j]; } } } return C; } void tr(Object... o) { System.out.println(Arrays.deepToString(o)); } }