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;
template <typename T>
inline void checkMax(T& a, const T& b) {
  if (a < b) a = b;
}
template <typename T>
inline void checkMin(T& a, const T& b) {
  if (a > b) a = b;
}
template <int MAX_DIM>
void LinearEquation(int n, double a[MAX_DIM][MAX_DIM], double b[MAX_DIM],
                    double x[MAX_DIM]) {
  int r;
  double p;
  for (int n___LINE__ = (n), i = 0; i < n___LINE__; ++i) {
    r = i;
    for (__typeof__(i + 1) f___LINE__ = (i + 1), t___LINE__ = (n - 1),
                           j = f___LINE__;
         j <= t___LINE__; ++j) {
      if (fabs(a[j][i]) > fabs(a[r][i])) r = j;
    }
    if (r != i)
      for (int n___LINE__ = (n), j = 0; j < n___LINE__; ++j) {
        swap(a[r][j], a[i][j]);
        swap(b[r], b[i]);
      }
    for (int n___LINE__ = (n), j = 0; j < n___LINE__; ++j)
      if (j != i) {
        p = -a[j][i] / a[i][i];
        for (int n___LINE__ = (n), k = 0; k < n___LINE__; ++k)
          a[j][k] += p * a[i][k];
        b[j] += p * b[i];
      }
  }
  for (int n___LINE__ = (n), i = 0; i < n___LINE__; ++i) x[i] = b[i] / a[i][i];
}
const int kMaxN = 110;
const int kMaxM = 5000 + 10;
const double eps = 1e-9;
double a[kMaxN][kMaxN], b[kMaxN], x[kMaxN];
int V, E;
int cnt[kMaxN][kMaxN];
int s[kMaxM], e[kMaxM], c[kMaxM];
bool used[kMaxN];
void dfs(int x) {
  used[x] = true;
  for (int n___LINE__ = (V), i = 0; i < n___LINE__; ++i)
    if ((!used[i]) && (cnt[x][i] > 0)) {
      dfs(i);
    }
}
int main() {
  scanf("%d%d", &V, &E);
  for (int n___LINE__ = (E), i = 0; i < n___LINE__; ++i)
    scanf("%d%d%d", s + i, e + i, c + i);
  do {
    memset(a, 0, sizeof(a));
  } while (0);
  do {
    memset(b, 0, sizeof(b));
  } while (0);
  do {
    memset(x, 0, sizeof(x));
  } while (0);
  do {
    memset(cnt, 0, sizeof(cnt));
  } while (0);
  do {
    memset(used, 0, sizeof(used));
  } while (0);
  for (int n___LINE__ = (E), i = 0; i < n___LINE__; ++i) {
    --s[i], --e[i];
    cnt[s[i]][e[i]]++;
    cnt[e[i]][s[i]]++;
  }
  dfs(0);
  if (!used[V - 1]) {
    for (int n___LINE__ = (E + 1), i = 0; i < n___LINE__; ++i) puts("0");
    return 0;
  }
  for (int n___LINE__ = (V), i = 0; i < n___LINE__; ++i)
    if (!used[i]) a[i][i] = 1.0;
  b[0] = 1.0;
  for (int n___LINE__ = (V - 1), i = 0; i < n___LINE__; ++i)
    if (used[i])
      for (int n___LINE__ = (V), j = 0; j < n___LINE__; ++j)
        if (i != j) {
          a[i][i] += cnt[i][j];
          a[i][j] -= cnt[i][j];
        }
  a[V - 1][V - 1] = 1.0;
  LinearEquation(V, a, b, x);
  double ans = 1e9, delta;
  for (int n___LINE__ = (E), i = 0; i < n___LINE__; ++i) {
    delta = fabs(x[e[i]] - x[s[i]]);
    if (delta > eps) checkMin(ans, c[i] / delta);
  }
  printf("%.9f\n", ans);
  for (int n___LINE__ = (E), i = 0; i < n___LINE__; ++i) {
    printf("%.9f\n", (x[s[i]] - x[e[i]]) * ans);
  }
  return 0;
}