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 MOD = 1000000007;
const int INF = 1000000001;
const long long int LLINF = 1000000000000000001LL;
struct PushRelabel {
  const long long int FINF = LLINF;
  struct edge {
    int v, revInd;
    long long int cap, flow;
  };
  int n, src, dest;
  queue<int> active;
  vector<vector<edge> > G;
  vector<long long int> exc;
  vector<int> height;
  PushRelabel(int n) : n(n), G(n), exc(n, 0), height(n, 0) {}
  void addEdge(int u, int v, long long int cap) {
    int sizeU = (int)(G[u]).size(), sizeV = (int)(G[v]).size();
    G[u].push_back({v, sizeV, cap, 0});
    G[v].push_back({u, sizeU, 0, 0});
  }
  bool special(int v) { return v == src || v == dest; }
  void push(int u, int ind) {
    int v = G[u][ind].v, rev = G[u][ind].revInd;
    long long int amount = min(exc[u], G[u][ind].cap - G[u][ind].flow);
    if (amount) {
      G[u][ind].flow += amount;
      G[v][rev].flow -= amount;
      exc[u] -= amount;
      exc[v] += amount;
      if (!special(v) && exc[v] == amount) active.push(v);
    }
  }
  void relabel(int u) {
    int minH = INF;
    for (const edge &e : G[u]) {
      if (e.flow < e.cap) minH = min(minH, height[e.v]);
    }
    height[u] = 1 + minH;
  }
  vector<int> revBfs(int s) {
    queue<int> Q;
    Q.push(s);
    vector<int> dist(n, -1);
    dist[s] = 0;
    while (!Q.empty()) {
      int q = Q.front();
      Q.pop();
      for (edge &e : G[q])
        if (dist[e.v] == -1) {
          edge &revEdge = G[e.v][e.revInd];
          if (revEdge.flow < revEdge.cap) {
            dist[e.v] = dist[q] + 1;
            Q.push(e.v);
          }
        }
    }
    return dist;
  }
  void globalRelabeling() {
    vector<int> srcDist = revBfs(src), destDist = revBfs(dest);
    for (int i = (0); i <= (n - 1); ++i) {
      if (i == src)
        height[i] = n;
      else if (destDist[i] != -1)
        height[i] = destDist[i];
      else if (srcDist[i] != -1)
        height[i] = n + srcDist[i];
    }
  }
  long long int getFlow(int src, int dest) {
    this->src = src;
    this->dest = dest;
    height[src] = n;
    exc[src] = FINF;
    for (int i = (0); i <= ((int)(G[src]).size() - 1); ++i) {
      push(src, i);
    }
    int itCount = 0;
    while (!active.empty()) {
      int v = active.front();
      active.pop();
      if (itCount % n == 0) {
        globalRelabeling();
      }
      for (int i = (0); i <= ((int)(G[v]).size() - 1); ++i) {
        int u = G[v][i].v;
        if (height[u] == height[v] - 1) {
          push(v, i);
        }
      }
      itCount++;
      if (exc[v]) {
        relabel(v);
        active.push(v);
      }
    }
    return exc[dest];
  }
  pair<long long int, vector<bool> > getCut(int src, int dest) {
    long long int value = getFlow(src, dest);
    vector<bool> seen(n, 0);
    queue<int> Q;
    Q.push(src);
    seen[src] = 1;
    while (!Q.empty()) {
      int q = Q.front();
      Q.pop();
      for (auto &e : G[q])
        if (!seen[e.v] && e.flow < e.cap) {
          seen[e.v] = 1;
          Q.push(e.v);
        }
    }
    return {value, seen};
  }
};
struct edge {
  int u, v;
  long long int cap;
};
struct GomoryHu {
  int n;
  vector<edge> G;
  GomoryHu(int n) : n(n) {}
  void addEdge(int u, int v, long long int cap) { G.push_back({u, v, cap}); }
  int fauFind(int x, vector<int> &par) {
    if (par[x] == -1)
      return x;
    else
      return par[x] = fauFind(par[x], par);
  }
  void fauJoin(int x, int y, vector<int> &par) {
    x = fauFind(x, par);
    y = fauFind(y, par);
    if (x != y) {
      par[x] = y;
    }
  }
  vector<int> assignLabels(int chosen, vector<vector<int> > &comp,
                           vector<edge> &tree) {
    int c = (int)(tree).size() + 1, cnt = 0;
    vector<int> fauPar(c, -1), labels(n, -1);
    for (int v : comp[chosen]) {
      labels[v] = cnt++;
    }
    for (auto &e : tree)
      if (e.u != chosen && e.v != chosen) {
        fauJoin(e.u, e.v, fauPar);
      }
    for (int i = (0); i <= ((int)(comp).size() - 1); ++i)
      if (i != chosen && fauPar[i] == -1) {
        for (int v : comp[i]) {
          labels[v] = cnt;
        }
        cnt++;
      }
    for (int i = (0); i <= ((int)(comp).size() - 1); ++i)
      if (i != chosen && fauPar[i] != -1) {
        int root = fauFind(i, fauPar);
        for (int v : comp[i]) {
          labels[v] = labels[comp[root][0]];
        }
      }
    return labels;
  }
  vector<edge> build() {
    vector<edge> tree;
    vector<vector<int> > comp(1);
    for (int i = (0); i <= (n - 1); ++i) {
      comp[0].push_back(i);
    }
    while ((int)(comp).size() < n) {
      int i = 0;
      while ((int)(comp[i]).size() == 1) i++;
      vector<int> labels = assignLabels(i, comp, tree);
      int numLabels = 1 + *max_element(labels.begin(), labels.end());
      PushRelabel flowNetwork(numLabels);
      for (auto &e : G) {
        flowNetwork.addEdge(labels[e.u], labels[e.v], e.cap);
        flowNetwork.addEdge(labels[e.v], labels[e.u], e.cap);
      }
      auto cut = flowNetwork.getCut(labels[comp[i][0]], labels[comp[i][1]]);
      vector<bool> inLeftPart = cut.second;
      vector<bool> inChosenComp(n, 0);
      for (int v : comp[i]) inChosenComp[v] = 1;
      comp.emplace_back();
      for (int j = (0); j <= ((int)(comp[i]).size() - 1); ++j)
        if (inLeftPart[j]) {
          comp.back().push_back(comp[i][j]);
          comp[i][j] = -1;
        }
      for (int j = (0); j <= ((int)(comp[i]).size() - 1); ++j)
        if (comp[i][j] == -1) {
          swap(comp[i][j], comp[i].back());
          comp[i].pop_back();
          j--;
        }
      int newVertex = (int)(comp).size() - 1;
      for (auto &e : tree) {
        if (e.v == i) swap(e.u, e.v);
        if (e.u == i) {
          int label = labels[comp[e.v][0]];
          if (inLeftPart[label]) {
            e.u = newVertex;
          }
        }
      }
      tree.push_back({i, newVertex, cut.first});
    }
    for (auto &e : tree) {
      e.u = comp[e.u][0];
      e.v = comp[e.v][0];
    }
    return tree;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  GomoryHu gomoryHu(n);
  for (int i = (1); i <= (m); ++i) {
    int u, v, c;
    cin >> u >> v >> c;
    u--;
    v--;
    gomoryHu.addEdge(u, v, c);
  }
  vector<edge> tree = gomoryHu.build();
  sort(tree.begin(), tree.end(),
       [](const edge &a, const edge &b) { return a.cap > b.cap; });
  vector<vector<int> > path(n);
  for (int i = (0); i <= (n - 1); ++i) path[i] = {i};
  long long int sum = 0;
  for (auto &e : tree) sum += e.cap;
  for (auto &e : tree) {
    copy(path[e.v].begin(), path[e.v].end(), back_inserter(path[e.u]));
    path[e.v].clear();
    edge cpy = e;
    for (auto &f : tree) {
      if (f.u == cpy.v) f.u = cpy.u;
      if (f.v == cpy.v) f.v = cpy.u;
    }
  }
  int i = 0;
  while (path[i].empty()) i++;
  cout << sum << '\n';
  for (int v : path[i]) {
    cout << 1 + v << ' ';
  }
  return 0;
}