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;
int N, M, ans;
int earn[202][202], w[202][202], mem[202][202];
int dist[202], cnt[203];
vector<int> con[202], order, path;
bool vis[202];
void bfs() {
  int i, k, q;
  queue<int> que;
  for (i = 0; i <= N + 1; i++) dist[i] = N + 2;
  for (i = 0; i <= N + 2; i++) cnt[i] = 0;
  dist[N + 1] = 0, que.push(N + 1);
  while (!que.empty()) {
    q = que.front();
    que.pop();
    for (i = ((int)(con[q]).size()); i--;) {
      k = con[q][i];
      if (w[k][q] && dist[k] == N + 2) dist[k] = dist[q] + 1, que.push(k);
    }
  }
  for (i = 0; i <= N + 1; i++) cnt[dist[i]]++;
}
int dfs(int n) {
  int i, k, ret;
  path.push_back(n);
  if (n == N + 1) return 1;
  for (i = ((int)(con[n]).size()); i--;) {
    k = con[n][i];
    if (w[n][k] && dist[k] + 1 == dist[n] && (ret = dfs(k))) return ret;
  }
  int tmp = dist[n];
  dist[n] = N + 2;
  for (i = ((int)(con[n]).size()); i--;) {
    k = con[n][i];
    if (w[n][k] && dist[n] > dist[k] + 1) dist[n] = dist[k] + 1;
  }
  cnt[dist[n]]++;
  if (!--cnt[tmp]) return -1;
  return 0;
}
int max_flow(int source, int sink) {
  memcpy(w, mem, sizeof(w));
  w[0][source] = 1e9;
  w[sink][N + 1] = 1e9;
  bfs();
  int ret = 0;
  while (dist[0] < N + 2) {
    path.clear();
    int val = dfs(0);
    if (val < 0) break;
    if (!val) continue;
    int flow = 2e9, i;
    for (i = 1; i < ((int)(path).size()); i++)
      flow = min(flow, w[path[i - 1]][path[i]]);
    for (i = 1; i < ((int)(path).size()); i++)
      w[path[i - 1]][path[i]] -= flow, w[path[i]][path[i - 1]] += flow;
    ret += flow;
  }
  return ret;
}
inline void addEdge(int s, int e, int f) {
  if (!w[s][e]) w[s][e] = w[e][s] = f, con[s].push_back(e), con[e].push_back(s);
}
int main() {
  int i, j, k, v;
  scanf("%d%d", &N, &M);
  for (i = 1; i <= M; i++) {
    scanf("%d%d%d", &j, &k, &v);
    addEdge(j, k, v);
  }
  memcpy(mem, w, sizeof(w));
  for (i = 1; i <= N; i++)
    con[0].push_back(i), con[i].push_back(0), con[i].push_back(N + 1),
        con[N + 1].push_back(i);
  for (i = 1; i <= N; i++)
    for (j = i + 1; j <= N; j++) {
      earn[i][j] = earn[j][i] = max_flow(i, j);
    }
  order.push_back(1);
  vis[1] = 1;
  while (((int)(order).size()) < N) {
    int n = order.back();
    int mx = -2e9, tar = 0;
    for (i = 1; i <= N; i++)
      if (!vis[i] && mx < earn[n][i]) mx = earn[n][i], tar = i;
    order.push_back(tar);
    vis[tar] = 1;
    ans += earn[n][tar];
  }
  printf("%d\n", ans);
  for (i = 0; i < ((int)(order).size()); i++) printf("%d ", order[i]);
  puts("");
}