Problem: Mad scientist Mike has applied for a job. His task is to manage a system of water pumping stations.

The system consists of n pumping stations, which are numbered by integers from 1 to n. Some pairs of stations are connected by bidirectional pipes through which water can flow in either direction (but only in one at a time). For each pipe you know its bandwidth — the maximum number of liters of water that can flow through it in one hour. Each pumping station can pump incoming water from some stations to other stations through the pipes, provided that in one hour the total influx of water to the station is equal to the total outflux of water from the station.

It is Mike's responsibility to pump water between stations. From station a to station b through the pipes (possibly through other stations) within one hour one can transmit a certain number of liters of water according to the rules described above. During this time, water from other stations can not flow into station a, and can not flow out of the station b. However, any amount of water can flow out of station a or in station b. If a total of x litres of water flows out of the station a in an hour, then Mike gets x bollars more to his salary.

To get paid, Mike needs to work for n - 1 days, according to the contract. On the first day he selects two stations v1 and v2, and within one hour he pumps a certain amount of water from v1 to v2. Next, on the i-th day Mike chooses a station vi + 1 that has been never selected before, and pumps a certain amount of water out of the station vi to station vi + 1 for one hour. The quantity of water he pumps on the i-th day does not depend on the amount of water pumped on the (i - 1)-th day.

Mike needs to earn as much bollars as he can for his projects. Help Mike find such a permutation of station numbers v1, v2, ..., vn so Mike will be able to earn the highest possible salary.

Input

The first line of the input contains two space-separated integers n and m (2 ≤ n ≤ 200, 1 ≤ m ≤ 1000) — the number of stations and pipes in the system, accordingly. The i-th of the next m lines contains three space-separated integers ai, bi and ci (1 ≤ ai, bi ≤ n, ai ≠ bi, 1 ≤ ci ≤ 100) — the numbers of stations connected by the i-th pipe and the pipe's bandwidth, accordingly. It is guaranteed that any two stations are connected by at most one pipe and that there is a pipe path between any two stations.

Output

On the first line print a single integer — the maximum salary Mike can earn.

On the second line print a space-separated permutation of n numbers from 1 to n — the numbers of stations in the sequence v1, v2, ..., vn. If there are multiple answers, print any of them.

Examples

Input

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


Output

77
6 2 1 5 3 4 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
int ss[N], ff[N], c[N], f[N], obr[N], pred[N], last[N], d[N], x[N];
int n, m, st, fin;
void add(int x, int y, int z, int xx, int yy) {
  m++;
  ss[m] = x;
  ff[m] = y;
  c[m] = z;
  f[m] = xx;
  obr[m] = yy;
}
bool expath() {
  for (int i = 1; i <= n; i++) d[i] = -1;
  int b = 1, e = 1;
  x[1] = st;
  d[st] = 0;
  while (b <= e) {
    int j = last[x[b]];
    while (j > 0) {
      if (c[j] > f[j] && d[ff[j]] == -1) {
        e++;
        x[e] = ff[j];
        d[x[e]] = d[x[b]] + 1;
        if (x[e] == fin) break;
      }
      j = pred[j];
    }
    if (x[e] == fin) break;
    b++;
  }
  return (d[fin] != -1);
}
int rec(int v, int w) {
  if (v == fin) return w;
  int r = 0, j = last[v];
  while (j > 0) {
    last[v] = pred[j];
    if (c[j] > f[j] && d[ff[j]] == d[v] + 1) {
      int ww = c[j] - f[j];
      if (w - r < ww) ww = w - r;
      int t = rec(ff[j], ww);
      if (t > 0) {
        f[j] += t;
        if (obr[j] != 0) f[obr[j]] -= t;
        r += t;
        if (r == w) break;
      }
    }
    j = pred[j];
  }
  return r;
}
int qs[N], qf[N], qd[N];
int es[N], ef[N], ed[N];
int g[N];
int idg[N], idv[N];
int qlast[N];
int user[N];
int num[N];
bool good[N];
int mx, km;
const int inf = (int)1e9;
void dfs(int v, int pr) {
  int j = last[v];
  while (j > 0) {
    if (good[num[j]]) {
      if (ef[j] != pr) {
        if (ed[j] < mx) {
          mx = ed[j];
          km = j;
        }
        dfs(ef[j], v);
      }
    }
    j = pred[j];
  }
}
bool first;
void solve(int v) {
  mx = inf;
  km = 0;
  dfs(v, 0);
  if (mx == inf) {
    if (!first) printf(" ");
    first = false;
    printf("%d", v);
    return;
  }
  good[num[km]] = false;
  int qm = km;
  solve(es[qm]);
  solve(ef[qm]);
}
int main() {
  int nn, mm;
  scanf("%d %d", &nn, &mm);
  for (int i = 1; i <= mm; i++) {
    scanf("%d %d %d", qs + i, qf + i, qd + i);
  }
  int kg = 1;
  for (int i = 1; i <= nn; i++) g[i] = 1;
  while (kg < nn) {
    int vs = -1, vf = -1;
    for (int i = 1; i <= nn; i++) {
      for (int j = i + 1; j <= nn; j++)
        if (g[i] == g[j]) {
          vs = i;
          vf = j;
          break;
        }
      if (vs != -1) break;
    }
    n = 0;
    for (int i = 1; i <= nn; i++)
      if (g[i] == g[vs]) idv[i] = ++n;
    for (int i = 1; i <= kg; i++)
      if (i != g[vs]) idg[i] = ++n;
    m = 0;
    for (int i = 1; i <= mm; i++) {
      int from = qs[i], to = qf[i];
      if (g[from] == g[vs])
        from = idv[from];
      else
        from = idg[g[from]];
      if (g[to] == g[vs])
        to = idv[to];
      else
        to = idg[g[to]];
      add(from, to, qd[i], 0, m + 2);
      add(to, from, qd[i], 0, m);
    }
    for (int i = 1; i <= n; i++) last[i] = 0;
    for (int i = 1; i <= m; i++) {
      pred[i] = last[ss[i]];
      last[ss[i]] = i;
    }
    for (int i = 1; i <= n; i++) qlast[i] = last[i];
    st = idv[vs];
    fin = idv[vf];
    int flow = 0;
    while (expath()) {
      int t = rec(st, 1000000);
      flow += t;
      for (int i = 1; i <= n; i++) last[i] = qlast[i];
    }
    for (int i = 1; i <= nn; i++)
      if (g[i] == g[vs] && d[idv[i]] == -1) g[i] = kg + 1;
    es[kg] = g[vs];
    ef[kg] = kg + 1;
    ed[kg] = flow;
    for (int i = 1; i < kg; i++) {
      if (es[i] == g[vs] && d[idg[ef[i]]] == -1) es[i] = kg + 1;
      if (ef[i] == g[vs] && d[idg[es[i]]] == -1) ef[i] = kg + 1;
    }
    kg++;
  }
  n = nn;
  for (int i = 1; i <= n; i++) user[g[i]] = i;
  for (int i = 1; i <= n - 1; i++) {
    es[i] = user[es[i]];
    ef[i] = user[ef[i]];
  }
  for (int i = 1; i <= n - 1; i++) {
    es[i + n - 1] = ef[i];
    ef[i + n - 1] = es[i];
    ed[i + n - 1] = ed[i];
    num[i + n - 1] = num[i] = i;
    good[i] = true;
  }
  for (int i = 1; i <= n; i++) last[i] = 0;
  for (int i = 1; i <= n + n - 2; i++) {
    pred[i] = last[es[i]];
    last[es[i]] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n - 1; i++) ans += ed[i];
  printf("%d\n", ans);
  first = true;
  solve(1);
  printf("\n");
  return 0;
}