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 = 200, M = 1000, INF = (1 << 30) - 1;
int n, m;
struct side0 {
  int x, y, f;
} a[M + 9];
void into() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].f);
}
int ans0;
struct side {
  int y, next, f;
} e[M * 5 + 9];
int lin[2][N + 9], cs;
void Ins(int id, int x, int y, int f) {
  e[++cs].y = y;
  e[cs].f = f;
  e[cs].next = lin[id][x];
  lin[id][x] = cs;
}
void Ins2(int id, int x, int y, int f) {
  if (!id) ans0 += f;
  Ins(id, x, y, f);
  Ins(id, y, x, f);
}
void Get_graph() {
  cs = n * 2 + 1;
  for (int i = 1; i <= n; ++i) lin[1][i] = 0;
  for (int i = 1; i <= m; ++i) Ins2(1, a[i].x, a[i].y, a[i].f);
}
int dis[N + 9];
queue<int> q;
bool Bfs_dis(int st, int td) {
  for (int i = 1; i <= n; ++i) dis[i] = 0;
  dis[st] = 1;
  q.push(st);
  for (; !q.empty();) {
    int t = q.front();
    q.pop();
    for (int i = lin[1][t]; i; i = e[i].next)
      if (e[i].f && !dis[e[i].y]) dis[e[i].y] = dis[t] + 1, q.push(e[i].y);
  }
  return dis[td];
}
int cur[N + 9];
int Dfs_flow(int k, int td, int f) {
  if (!f || k == td) return f;
  int res = 0;
  for (int &i = cur[k]; i; i = e[i].next)
    if (e[i].f && dis[k] + 1 == dis[e[i].y]) {
      int t = Dfs_flow(e[i].y, td, min(f, e[i].f));
      if (!t) dis[e[i].y] = 0;
      f -= t;
      res += t;
      e[i].f -= t;
      e[i ^ 1].f += t;
      if (!f) return res;
    }
  return res;
}
int Max_flow(int st, int td) {
  int res = 0;
  for (; Bfs_dis(st, td); res += Dfs_flow(st, td, INF))
    for (int i = 1; i <= n; ++i) cur[i] = lin[1][i];
  return res;
}
int vis[M + 9];
void Dfs_vis(int k) {
  vis[k] = 1;
  for (int i = lin[1][k]; i; i = e[i].next)
    if (e[i].f && !vis[e[i].y]) Dfs_vis(e[i].y);
}
void Divide_tree(vector<int> &d) {
  if (d.size() == 1) return;
  int tmp = cs;
  Get_graph();
  cs = tmp;
  Ins2(0, d[0], d[1], Max_flow(d[0], d[1]));
  for (int i = 1; i <= n; ++i) vis[i] = 0;
  Dfs_vis(d[0]);
  vector<int> d0, d1;
  for (int vs = d.size(), i = 0; i < vs; ++i)
    vis[d[i]] ? d0.push_back(d[i]) : d1.push_back(d[i]);
  Divide_tree(d0);
  Divide_tree(d1);
}
void Gomory_hu() {
  cs = 1;
  vector<int> d;
  for (int i = 1; i <= n; ++i) d.push_back(i);
  Divide_tree(d);
  for (int i = 1; i <= n; ++i) vis[i] = 0;
  e[0].f = INF;
}
int Dfs_min(int k, int fa) {
  int res = 0;
  for (int i = lin[0][k]; i; i = e[i].next)
    if (!vis[i] && e[i].y ^ fa) {
      int t = Dfs_min(e[i].y, k);
      if (e[i].f < e[t].f) t = i;
      if (e[t].f < e[res].f) res = t;
    }
  return res;
}
vector<int> ans;
void Divide_ans(int k) {
  int flag = 1;
  for (int i = lin[0][k]; i; i = e[i].next) flag &= vis[i];
  if (flag) {
    ans.push_back(k);
    return;
  }
  int t = Dfs_min(k, 0);
  vis[t] = vis[t ^ 1] = 1;
  Divide_ans(e[t].y);
  Divide_ans(e[t ^ 1].y);
}
void work() {
  Gomory_hu();
  Divide_ans(1);
}
void outo() {
  printf("%d\n", ans0);
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
  puts("");
}
int main() {
  into();
  work();
  outo();
  return 0;
}