Problem: Berland traffic is very different from traffic in other countries. The capital of Berland consists of n junctions and m roads. Each road connects a pair of junctions. There can be multiple roads between a pair of junctions. For each road we know its capacity: value ci is the maximum number of cars that can drive along a road in any direction per a unit of time. For each road, the cars can drive along it in one of two direction. That it, the cars can't simultaneously move in both directions. A road's traffic is the number of cars that goes along it per a unit of time. For road (ai, bi) this value is negative, if the traffic moves from bi to ai. A road's traffic can be a non-integer number.

The capital has two special junctions — the entrance to the city (junction 1) and the exit from the city (junction n). For all other junctions it is true that the traffic is not lost there. That is, for all junctions except for 1 and n the incoming traffic sum equals the outgoing traffic sum.

Traffic has an unusual peculiarity in the capital of Berland — for any pair of junctions (x, y) the sum of traffics along any path from x to y doesn't change depending on the choice of the path. Such sum includes traffic along all roads on the path (possible with the "minus" sign, if the traffic along the road is directed against the direction of the road on the path from x to y).

Your task is to find the largest traffic that can pass trough the city per one unit of time as well as the corresponding traffic for each road. 

Input

The first line contains a positive integer n — the number of junctions (2 ≤ n ≤ 100). The second line contains integer m (1 ≤ m ≤ 5000) — the number of roads. Next m lines contain the roads' descriptions. Each road contains a group of three numbers ai, bi, ci, where ai, bi are the numbers of junctions, connected by the given road, and ci (1 ≤ ai, bi ≤ n; ai ≠ bi; 0 ≤ ci ≤ 10000) is the largest permissible traffic along this road.

Output

In the first line print the required largest traffic across the city. Then print m lines, on each line print the speed, at which the traffic moves along the corresponding road. If the direction doesn't match the order of the junctions, given in the input, then print the traffic with the minus sign. Print the numbers with accuracy of at least five digits after the decimal point.

If there are many optimal solutions, print any of them.

Examples

Input

2
3
1 2 2
1 2 4
2 1 1000


Output

6.00000
2.00000
2.00000
-2.00000


Input

7
11
1 2 7
1 2 7
1 3 7
1 4 7
2 3 7
2 5 7
3 6 7
4 7 7
5 4 7
5 6 7
6 7 7


Output

13.00000
2.00000
2.00000
3.00000
6.00000
1.00000
3.00000
4.00000
7.00000
1.00000
2.00000
6.00000

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int V, E;
int v1[5010], v2[5010], c[5010];
int cnt[110][110];
double cap[110][110];
bool used[110];
void dfs(int x) {
  if (used[x]) return;
  used[x] = true;
  int i;
  for ((i) = 0; (i) < (int)(V); (i)++)
    if (cnt[x][i] > 0) dfs(i);
}
double a[110][110], b[110], x[110];
void linear_equation(int N) {
  int i, j, k;
  for ((i) = 0; (i) < (int)(N); (i)++) {
    int r = i;
    for (j = i + 1; j < N; j++)
      if (((a[j][i]) > 0 ? (a[j][i]) : -(a[j][i])) >
          ((a[r][i]) > 0 ? (a[r][i]) : -(a[r][i])))
        r = j;
    if (r != i) {
      for ((j) = 0; (j) < (int)(N); (j)++) swap(a[r][j], a[i][j]);
      swap(b[r], b[i]);
    }
    for ((j) = 0; (j) < (int)(N); (j)++)
      if (j != i) {
        double p = -a[j][i] / a[i][i];
        for (k = i; k < N; k++) a[j][k] += a[i][k] * p;
        b[j] += b[i] * p;
      }
  }
  for ((i) = 0; (i) < (int)(N); (i)++) x[i] = b[i] / a[i][i];
}
int main(void) {
  int i, j;
  cin >> V >> E;
  for ((i) = 0; (i) < (int)(E); (i)++) {
    cin >> v1[i] >> v2[i] >> c[i];
    v1[i]--;
    v2[i]--;
  }
  for ((i) = 0; (i) < (int)(E); (i)++) {
    cnt[v1[i]][v2[i]]++;
    cnt[v2[i]][v1[i]]++;
  }
  dfs(0);
  if (!used[V - 1]) {
    for ((i) = 0; (i) < (int)(E + 1); (i)++) cout << 0 << endl;
    return 0;
  }
  for ((i) = 0; (i) < (int)(V); (i)++)
    if (!used[i]) a[i][i] = 1.0;
  b[0] = 1.0;
  for ((i) = 0; (i) < (int)(V - 1); (i)++)
    if (used[i])
      for ((j) = 0; (j) < (int)(V); (j)++)
        if (j != i) {
          a[i][i] += cnt[i][j];
          a[i][j] -= cnt[i][j];
        }
  a[V - 1][V - 1] = 1.0;
  b[V - 1] = 0.0;
  linear_equation(V);
  for ((i) = 0; (i) < (int)(V); (i)++)
    for ((j) = 0; (j) < (int)(V); (j)++)
      if (cnt[i][j] > 0) cap[i][j] = 10000.0;
  for ((i) = 0; (i) < (int)(E); (i)++) {
    cap[v1[i]][v2[i]] = min(cap[v1[i]][v2[i]], (double)c[i]);
    cap[v2[i]][v1[i]] = min(cap[v2[i]][v1[i]], (double)c[i]);
  }
  double ans = 1.0E+9;
  for ((i) = 0; (i) < (int)(V); (i)++)
    for ((j) = 0; (j) < (int)(V); (j)++)
      if (cnt[i][j] > 0) {
        double tmp = x[i] - x[j];
        if (tmp < 0.0) tmp = -tmp;
        if (tmp > 1.0E-9) ans = min(ans, cap[i][j] / tmp);
      }
  printf("%.9f\n", ans);
  for ((i) = 0; (i) < (int)(E); (i)++)
    printf("%.9f\n", (x[v1[i]] - x[v2[i]]) * ans);
  return 0;
}