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 M = 2005;
int n, m, q;
int read() {
  int x = 0, y = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') y = (ch == '-' ? -1 : 1), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * y;
}
struct Edge {
  int nxt, to, w;
};
namespace NetWork_Flow {
Edge e[M << 1];
int tot = 1, first[M], cur[M];
void add(int x, int y, int w) {
  e[++tot] = (Edge){first[x], y, w};
  first[x] = tot;
}
void addedge(int x, int y, int w) { add(x, y, w), add(y, x, 0); }
int S, T, de[M];
queue<int> Q;
bool bfs() {
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= n; i++) cur[i] = first[i], de[i] = 0;
  Q.push(S);
  de[S] = 1;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i = first[u]; i; i = e[i].nxt) {
      int v = e[i].to;
      if (!e[i].w || de[v]) continue;
      de[v] = de[u] + 1;
      Q.push(v);
      if (v == T) return 1;
    }
  }
  return 0;
}
int dfs(int u, int flow) {
  if (u == T || !flow) return flow;
  int f, tmp = 0;
  for (int i = cur[u]; i; i = cur[u] = e[i].nxt) {
    int v = e[i].to, w = e[i].w;
    if (de[v] != de[u] + 1 || !(f = dfs(v, min(w, flow - tmp)))) continue;
    e[i].w -= f, e[i ^ 1].w += f, tmp += f;
    if (tmp == flow) break;
  }
  return tmp;
}
void Init() {
  for (int i = 2; i <= tot; i += 2) e[i].w += e[i ^ 1].w, e[i ^ 1].w = 0;
}
int Dinic() {
  Init();
  int res = 0;
  while (bfs()) res += dfs(S, 1e9);
  return res;
}
}  // namespace NetWork_Flow
namespace MinCut_Tree {
Edge e[M];
int tot = 1, first[M], cur[M];
void add(int x, int y, int w) {
  e[++tot] = (Edge){first[x], y, w};
  first[x] = tot;
}
int d[M], t[M];
void Build(int l, int r) {
  if (l >= r) return;
  NetWork_Flow::S = d[l], NetWork_Flow::T = d[r];
  int Cut = NetWork_Flow::Dinic();
  int L = l, R = r;
  for (int i = l + 1; i < r; i++) {
    if (NetWork_Flow::de[d[i]])
      t[++L] = d[i];
    else
      t[--R] = d[i];
  }
  add(d[l], d[r], Cut), add(d[r], d[l], Cut);
  for (int i = l + 1; i < r; i++) d[i] = t[i];
  Build(l, L), Build(R, r);
}
int de[M], fath[M][15], minn[M][15];
void dfs(int u, int fa) {
  de[u] = de[fa] + 1;
  fath[u][0] = fa;
  for (int i = 1; i <= 10; i++)
    fath[u][i] = fath[fath[u][i - 1]][i - 1],
    minn[u][i] = min(minn[u][i - 1], minn[fath[u][i - 1]][i - 1]);
  for (int i = first[u]; i; i = e[i].nxt) {
    int v = e[i].to, w = e[i].w;
    if (v == fa) continue;
    minn[v][0] = w;
    dfs(v, u);
  }
}
int Get_min(int x, int y) {
  int res = 1e9;
  if (de[x] < de[y]) swap(x, y);
  for (int i = 10; i >= 0; i--)
    if (de[fath[x][i]] >= de[y]) res = min(res, minn[x][i]), x = fath[x][i];
  if (x == y) return res;
  for (int i = 10; i >= 0; i--)
    if (fath[x][i] != fath[y][i])
      res = min(res, min(minn[x][i], minn[y][i])), x = fath[x][i],
      y = fath[y][i];
  return min(res, min(minn[x][0], minn[y][0]));
}
}  // namespace MinCut_Tree
using namespace MinCut_Tree;
bool vis[M];
int a[M], Ans[M], mc[M][M];
void Find(int u, int id) {
  int Max = -1, x;
  vis[a[id] = u] = 1;
  if (id == n) return;
  for (int i = 1; i <= n; i++)
    if (!vis[i] && mc[u][i] > Max) Max = mc[u][i], x = i;
  a[0] += Max, Find(x, id + 1);
}
void solve() {
  n = read(), m = read(), Ans[0] = -1;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), w = read();
    NetWork_Flow::addedge(x, y, w), NetWork_Flow::addedge(y, x, w);
  }
  for (int i = 1; i <= n; i++) d[i] = i;
  Build(1, n);
  dfs(1, 0);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++) mc[i][j] = mc[j][i] = Get_min(i, j);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) vis[j] = 0;
    a[0] = 0, Find(i, 1);
    if (a[0] > Ans[0])
      for (int j = 0; j <= n; j++) Ans[j] = a[j];
  }
  printf("%d\n", Ans[0]);
  for (int i = 1; i <= n; i++) printf("%d ", Ans[i]);
  printf("\n");
}
signed main() { solve(); }