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 <class C>
void mini(C& _a4, C _b4) {
  _a4 = min(_a4, _b4);
}
template <class C>
void maxi(C& _a4, C _b4) {
  _a4 = max(_a4, _b4);
}
template <class TH>
void _dbg(const char* sdbg, TH h) {
  cerr << sdbg << '=' << h << endl;
}
template <class TH, class... TA>
void _dbg(const char* sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << '=' << h << ',';
  _dbg(sdbg + 1, a...);
}
struct Dinic {
  struct Edge {
    long long v, c, inv;
  };

 public:
  Dinic() { n = -1; }
  void AddEdge(long long a, long long b, long long cap, long long bi_dir) {
    if (n < max(a, b)) {
      n = max(n, max(a, b));
      ResizeVectors();
    }
    e_orig[a].push_back(Edge{b, cap, ((long long)(e_orig[b]).size())});
    e_orig[b].push_back(
        Edge{a, bi_dir * cap, ((long long)(e_orig[a]).size()) - 1});
  }
  long long MaxFlow(long long s, long long t) {
    e = e_orig;
    long long result = 0;
    while (Bfs(s, t)) {
      for (long long i = 0; i <= n; i++) {
        beg[i] = 0;
      }
      result += Dfs(s, t, kInf);
    }
    return result;
  }
  vector<bool> MinCut(long long s, long long t) {
    assert(!Bfs(s, t));
    vector<bool> res(n + 1);
    for (long long i = 0; i <= n; i++) {
      if (dis[i] <= n) {
        res[i] = true;
      }
    }
    return res;
  }

 private:
  long long n;
  vector<vector<Edge>> e_orig, e;
  vector<long long> dis, beg;
  vector<pair<long long, long long>> cut;
  bool Bfs(long long s, long long t) {
    for (long long i = 0; i <= n; i++) {
      dis[i] = n + 1;
    }
    dis[s] = 0;
    vector<long long> que;
    que.push_back(s);
    for (long long i = 0; i < ((long long)(que).size()); i++) {
      long long v = que[i];
      for (auto edge : e[v]) {
        long long nei = edge.v;
        if (edge.c && dis[nei] > dis[v] + 1) {
          dis[nei] = dis[v] + 1;
          que.push_back(nei);
          if (nei == t) {
            cut.clear();
            return true;
          }
        } else if (!edge.c) {
          cut.push_back(make_pair(v, nei));
        }
      }
    }
    return false;
  }
  long long Dfs(long long v, long long t, long long min_cap) {
    long long result = 0;
    if (v == t || min_cap == 0) {
      return min_cap;
    }
    for (long long& i = beg[v]; i < ((long long)(e[v]).size()); i++) {
      long long nei = e[v][i].v;
      long long c = e[v][i].c;
      if (dis[nei] == dis[v] + 1 && c > 0) {
        long long flow_here = Dfs(nei, t, min(min_cap, c));
        result += flow_here;
        min_cap -= flow_here;
        e[v][i].c -= flow_here;
        e[nei][e[v][i].inv].c += flow_here;
      }
      if (min_cap == 0) {
        break;
      }
    }
    return result;
  }
  void ResizeVectors() {
    e_orig.resize(n + 2);
    beg.resize(n + 2);
    dis.resize(n + 2);
  }
  static const long long kInf = 1e18;
};
struct GomoryHu {
  vector<vector<pair<long long, long long>>> graph;
  vector<vector<long long>> nodes;
  vector<bool> visited;
  vector<long long> groupId, contrId;
  vector<long long> edgeFrom, edgeTo, edgeLen;
  long long wnode;
  long long n;
  GomoryHu(long long N) : graph(N), visited(N), groupId(N), contrId(N), n(N) {}
  void addEdge(long long u, long long v, long long cap) {
    graph[u].emplace_back(v, cap);
    graph[v].emplace_back(u, cap);
  }
  void dfs(long long v, long long type) {
    visited[v] = true;
    contrId[v] = type;
    for (long long i = 0; i < ((long long)(edgeFrom).size()); i++) {
      if (edgeFrom[i] == v && !visited[edgeTo[i]]) {
        dfs(edgeTo[i], type);
      }
    }
  }
  vector<vector<pair<long long, long long>>> run() {
    vector<long long> allNodes(n);
    iota((allNodes).begin(), (allNodes).end(), 0);
    nodes = vector<vector<long long>>{allNodes};
    edgeFrom.clear();
    edgeTo.clear();
    edgeLen.clear();
    fill((groupId).begin(), (groupId).end(), 0);
    for (long long step = 0; step < n - 1; step++) {
      Dinic dinic;
      for (long long i = 0; i < ((long long)(nodes).size()); i++) {
        if (((long long)(nodes[i]).size()) > 1) {
          wnode = i;
          break;
        }
      }
      random_shuffle((nodes[wnode]).begin(), (nodes[wnode]).end());
      fill((visited).begin(), (visited).end(), false);
      visited[wnode] = true;
      for (long long i = 0; i < ((long long)(edgeFrom).size()); i++) {
        if (edgeFrom[i] == wnode) {
          dfs(edgeTo[i], edgeTo[i]);
        }
      }
      for (long long v = 0; v < n; v++) {
        long long a = groupId[v] == wnode ? v : contrId[groupId[v]] + n;
        for (auto& P : graph[v]) {
          long long b = groupId[P.first] == wnode
                            ? P.first
                            : contrId[groupId[P.first]] + n;
          dinic.AddEdge(a, b, P.second, 0);
        }
      }
      dinic.AddEdge(2 * n, 2 * n, 0, 0);
      long long a = nodes[wnode][0], b = nodes[wnode][1],
                f = dinic.MaxFlow(a, b);
      auto cut = dinic.MinCut(a, b);
      for (long long i = 0; i < ((long long)(edgeFrom).size()); i++) {
        if (edgeFrom[i] != wnode && edgeTo[i] == wnode &&
            !cut[edgeFrom[i] + n]) {
          edgeTo[i] = step + 1;
        }
        if (edgeTo[i] != wnode && edgeFrom[i] == wnode && !cut[edgeTo[i] + n]) {
          edgeFrom[i] = step + 1;
        }
      }
      edgeFrom.push_back(wnode);
      edgeTo.push_back(step + 1);
      edgeLen.push_back(f);
      edgeFrom.push_back(step + 1);
      edgeTo.push_back(wnode);
      edgeLen.push_back(f);
      vector<long long> A, B;
      for (long long v : nodes[wnode]) {
        (cut[v] ? A : B).push_back(v);
        if (!cut[v]) {
          groupId[v] = step + 1;
        }
      }
      nodes[wnode] = A;
      nodes.push_back(B);
    }
    vector<vector<pair<long long, long long>>> tree(n);
    for (long long i = 0; i < ((long long)(edgeFrom).size()); i++) {
      tree[nodes[edgeFrom[i]][0]].emplace_back(nodes[edgeTo[i]][0], edgeLen[i]);
    }
    return tree;
  }
};
int main() {
  long long N, M;
  cin >> N >> M;
  GomoryHu gomory(N);
  for (long long i = 0; i < M; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    gomory.addEdge(u - 1, v - 1, c);
  }
  auto V = gomory.run();
  vector<long long> connRoot(N);
  vector<list<long long>> vertList(N);
  iota((connRoot).begin(), (connRoot).end(), 0);
  for (long long i = 0; i < N; i++) {
    vertList[i].push_back(i);
  }
  vector<tuple<long long, long long, long long>> edges;
  for (long long i = 0; i < N; i++) {
    for (auto& P : V[i]) {
      if (i < P.first) {
        edges.emplace_back(-P.second, i, P.first);
      }
    }
  }
  sort((edges).begin(), (edges).end());
  long long sum = 0;
  for (auto E : edges) {
    long long from = get<1>(E), to = get<2>(E);
    sum -= get<0>(E);
    from = connRoot[from];
    to = connRoot[to];
    if (from > to) {
      swap(from, to);
    }
    (from, to);
    vertList[from].splice(vertList[from].end(), vertList[to]);
    for (long long i = 0; i < N; i++) {
      if (connRoot[i] == to) {
        connRoot[i] = from;
      }
    }
  }
  cout << sum << "\n";
  for (long long v : vertList[0]) {
    cout << v + 1 << " ";
  }
  cout << "\n";
}