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;
template <int SZ>
struct Dinic {
  typedef long long F;
  struct Edge {
    int to, rev;
    F flow, cap;
  };
  int N, s, t;
  vector<Edge> adj[SZ];
  typename vector<Edge>::iterator cur[SZ];
  void addEdge(int u, int v, F cap) {
    assert(cap >= 0);
    Edge a{v, (int)adj[v].size(), 0, cap}, b{u, (int)adj[u].size(), 0, 0};
    adj[u].push_back(a), adj[v].push_back(b);
  }
  int level[SZ];
  bool bfs() {
    for (int i = 0; i < N; i++) level[i] = -1, cur[i] = begin(adj[i]);
    queue<int> q({s});
    level[s] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (auto &e : adj[u])
        if (level[e.to] < 0 && e.flow < e.cap)
          q.push(e.to), level[e.to] = level[u] + 1;
    }
    return level[t] >= 0;
  }
  F sendFlow(int v, F flow) {
    if (v == t) return flow;
    for (; cur[v] != end(adj[v]); cur[v]++) {
      Edge &e = *cur[v];
      if (level[e.to] != level[v] + 1 || e.flow == e.cap) continue;
      auto df = sendFlow(e.to, min(flow, e.cap - e.flow));
      if (df) {
        e.flow += df;
        adj[e.to][e.rev].flow -= df;
        return df;
      }
    }
    return 0;
  }
  F maxFlow(int n, int _s, int _t) {
    N = n, s = _s, t = _t;
    if (s == t) return -1;
    F tot = 0;
    while (bfs())
      while (auto df = sendFlow(s, numeric_limits<F>::max())) tot += df;
    return tot;
  }
};
template <int SZ>
struct GomoryHu {
  int N;
  vector<pair<pair<int, int>, int>> ed;
  void addEdge(int a, int b, int c) { ed.push_back({{a, b}, c}); }
  vector<vector<int>> cor = {{}};
  map<int, int> adj[2 * SZ];
  int side[SZ];
  int gen(vector<vector<int>> cc) {
    Dinic<SZ> D = Dinic<SZ>();
    vector<int> comp(N + 1);
    for (int i = 0; i < cc.size(); i++)
      for (auto &t : cc[i]) comp[t] = i;
    for (auto &t : ed)
      if (comp[t.first.first] != comp[t.first.second]) {
        D.addEdge(comp[t.first.first], comp[t.first.second], t.second);
        D.addEdge(comp[t.first.second], comp[t.first.first], t.second);
      }
    int f = D.maxFlow(N, 0, 1);
    for (int i = 0; i < cc.size(); i++)
      for (auto &j : cc[i]) side[j] = D.level[i] >= 0;
    return f;
  }
  void fill(vector<int> &v, int a, int b) {
    for (auto &t : cor[a]) v.push_back(t);
    for (auto &t : adj[a])
      if (t.first != b) fill(v, t.first, a);
  }
  void addTree(int a, int b, int c) { adj[a][b] = c, adj[b][a] = c; }
  void delTree(int a, int b) { adj[a].erase(b), adj[b].erase(a); }
  vector<pair<pair<int, int>, int>> init(int n) {
    N = n;
    for (int i = 1; i <= N; i++) cor[0].push_back(i);
    queue<int> todo;
    todo.push(0);
    while (!todo.empty()) {
      int x = todo.front();
      todo.pop();
      vector<vector<int>> cc;
      for (auto &t : cor[x]) cc.push_back({t});
      for (auto &t : adj[x]) {
        cc.push_back({});
        fill(cc.back(), t.first, x);
      }
      int f = gen(cc);
      cor.push_back({}), cor.push_back({});
      for (auto &t : cor[x]) cor[cor.size() - 2 + side[t]].push_back(t);
      for (int i = 0; i < 2; i++)
        if (cor[cor.size() - 2 + i].size() > 1) todo.push(cor.size() - 2 + i);
      for (int i = 0; i < cor.size() - 2; i++)
        if (i != x && adj[i].count(x)) {
          addTree(i, cor.size() - 2 + side[cor[i][0]], adj[i][x]);
          delTree(i, x);
        }
      addTree(cor.size() - 2, cor.size() - 1, f);
    }
    vector<pair<pair<int, int>, int>> ans;
    for (int i = 0; i < cor.size(); i++)
      for (auto &j : adj[i])
        if (i < j.first)
          ans.push_back({{cor[i][0], cor[j.first][0]}, j.second});
    return ans;
  }
  void dfs(int root, int node, int parent, int minimum,
           vector<vector<pair<int, int>>> &edges, vector<vector<int>> &f) {
    f[root][node] = minimum;
    for (pair<int, int> edge : edges[node])
      if (edge.first != parent)
        dfs(root, edge.first, node, min(minimum, edge.second), edges, f);
  }
  vector<vector<int>> allPairs(int n) {
    auto tree = init(n);
    vector<vector<int>> ret(n + 1, vector<int>(n + 1, 0));
    vector<vector<pair<int, int>>> edges(n + 1);
    for (auto e : tree) {
      edges[e.first.first].emplace_back(e.first.second, e.second);
      edges[e.first.second].emplace_back(e.first.first, e.second);
    }
    for (int i = 1; i <= n; i++) dfs(i, i, i, INT_MAX, edges, ret);
    return ret;
  }
};
int n, m, ans, maxi = -1, ma, mb, parent[220];
vector<int> order;
vector<pair<int, int>> adj[220];
int main() {
  GomoryHu<220> gh;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    gh.addEdge(a, b, c);
  }
  auto tree = gh.init(n);
  for (auto ed : tree) {
    int a = ed.first.first, b = ed.first.second, c = ed.second;
    ans += c;
    if (maxi < c) {
      maxi = c;
      tie(ma, mb) = ed.first;
    }
    adj[a].emplace_back(c, b);
    adj[b].emplace_back(c, a);
  }
  order.push_back(ma);
  order.push_back(mb);
  priority_queue<pair<int, int>> thankyounext;
  for (auto ed : adj[ma])
    if (ed.second != mb) thankyounext.push(ed), parent[ed.second] = ma;
  for (auto ed : adj[mb])
    if (ed.second != ma) thankyounext.push(ed), parent[ed.second] = mb;
  while (!thankyounext.empty()) {
    int u = thankyounext.top().second;
    thankyounext.pop();
    order.push_back(u);
    for (auto ed : adj[u])
      if (ed.second != parent[u]) thankyounext.push(ed), parent[ed.second] = u;
  }
  printf("%d\n", ans);
  for (int x : order) printf("%d ", x);
  return 0;
}