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;
struct MaxFlow {
  const long long INF = 1e18;
  struct Edge {
    int u, v;
    long long c, rc;
    shared_ptr<long long> flow;
    Edge(int _u, int _v, long long _c, long long _rc = 0)
        : u(_u), v(_v), c(_c), rc(_rc) {}
  };
  struct FlowTracker {
    shared_ptr<long long> flow;
    long long cap, rcap;
    bool dir;
    FlowTracker(long long _cap, long long _rcap, shared_ptr<long long> _flow,
                int _dir)
        : cap(_cap), rcap(_rcap), flow(_flow), dir(_dir) {}
    long long rem() const {
      if (dir == 0) {
        return cap - *flow;
      } else {
        return rcap + *flow;
      }
    }
    void add_flow(long long f) {
      if (dir == 0)
        *flow += f;
      else
        *flow -= f;
      assert(*flow <= cap);
      assert(-*flow <= rcap);
    }
    operator long long() const { return rem(); }
    void operator-=(long long x) { add_flow(x); }
    void operator+=(long long x) { add_flow(-x); }
  };
  int source, sink;
  vector<vector<int>> adj;
  vector<vector<FlowTracker>> cap;
  vector<Edge> edges;
  MaxFlow(int _source, int _sink) : source(_source), sink(_sink) {
    assert(source != sink);
  }
  int add_edge(int u, int v, long long c, long long rc = 0) {
    edges.push_back(Edge(u, v, c, rc));
    return edges.size() - 1;
  }
  vector<int> now, lvl;
  void prep() {
    int max_id = max(source, sink);
    for (auto edge : edges) max_id = max(max_id, max(edge.u, edge.v));
    adj.resize(max_id + 1);
    cap.resize(max_id + 1);
    now.resize(max_id + 1);
    lvl.resize(max_id + 1);
    for (auto &edge : edges) {
      auto flow = make_shared<long long>(0);
      adj[edge.u].push_back(edge.v);
      cap[edge.u].push_back(FlowTracker(edge.c, edge.rc, flow, 0));
      if (edge.u != edge.v) {
        adj[edge.v].push_back(edge.u);
        cap[edge.v].push_back(FlowTracker(edge.c, edge.rc, flow, 1));
      }
      assert(cap[edge.u].back() == edge.c);
      edge.flow = flow;
    }
  }
  bool dinic_bfs() {
    fill(now.begin(), now.end(), 0);
    fill(lvl.begin(), lvl.end(), 0);
    lvl[source] = 1;
    vector<int> bfs(1, source);
    for (int i = 0; i < bfs.size(); ++i) {
      int u = bfs[i];
      for (int j = 0; j < adj[u].size(); ++j) {
        int v = adj[u][j];
        if (cap[u][j] > 0 && lvl[v] == 0) {
          lvl[v] = lvl[u] + 1;
          bfs.push_back(v);
        }
      }
    }
    return lvl[sink] > 0;
  }
  long long dinic_dfs(int u, long long flow) {
    if (u == sink) return flow;
    while (now[u] < adj[u].size()) {
      int v = adj[u][now[u]];
      if (lvl[v] == lvl[u] + 1 && cap[u][now[u]] != 0) {
        long long res = dinic_dfs(v, min(flow, (long long)cap[u][now[u]]));
        if (res > 0) {
          cap[u][now[u]] -= res;
          return res;
        }
      }
      ++now[u];
    }
    return 0;
  }
  long long calc_max_flow() {
    prep();
    long long ans = 0;
    while (dinic_bfs()) {
      long long cur = 0;
      do {
        cur = dinic_dfs(source, INF);
        ans += cur;
      } while (cur > 0);
    }
    return ans;
  }
  long long flow_on_edge(int edge_index) {
    assert(edge_index < edges.size());
    return *edges[edge_index].flow;
  }
};
struct Edge {
  int u, v, w;
  Edge() {}
  Edge(int _u, int _v, int _w) : u(_u), v(_v), w(_w) {}
};
class GomoryHu {
  int vertexc;
  vector<vector<int>> capac;
  vector<int> comp;
  vector<int> compsz;
  vector<Edge> tree_edges;
  void find_cut(int vertex, int source, vector<int> &partition,
                vector<vector<int>> &curcapac, vector<vector<int>> &indices,
                MaxFlow &mf) {
    partition[vertex] = 1;
    for (int nxt = 0; nxt < vertexc; nxt++) {
      if (comp[nxt] == source || comp[nxt] == nxt) {
        if (!partition[nxt]) {
          if (curcapac[vertex][nxt] > 0) {
            if (abs(mf.flow_on_edge(indices[vertex][nxt])) <
                curcapac[vertex][nxt]) {
              find_cut(nxt, source, partition, curcapac, indices, mf);
            }
          }
        }
      }
    }
  }
  void split_component(int vertex) {
    int source = vertex;
    int sink = -1;
    for (int i = 0; i < vertexc; i++) {
      if (comp[i] == vertex && i != vertex) {
        sink = i;
      }
    }
    vector<vector<int>> newcapac(vertexc, vector<int>(vertexc, 0));
    for (int i = 0; i < vertexc; i++) {
      int ic = (comp[i] == vertex ? i : comp[i]);
      for (int j = 0; j < vertexc; j++) {
        int jc = (comp[j] == vertex ? j : comp[j]);
        newcapac[ic][jc] += capac[i][j];
      }
    }
    vector<vector<int>> edgeIndices(vertexc, vector<int>(vertexc, 0));
    MaxFlow mf(source, sink);
    for (int i = 0; i < vertexc; i++) {
      if (comp[i] == vertex || comp[i] == i) {
        for (int j = i + 1; j < vertexc; j++) {
          if (comp[j] == vertex || comp[j] == j) {
            if (newcapac[i][j] > 0) {
              edgeIndices[i][j] =
                  mf.add_edge(i, j, newcapac[i][j], newcapac[i][j]);
              edgeIndices[j][i] = edgeIndices[i][j];
            }
          }
        }
      }
    }
    int newWeight = mf.calc_max_flow();
    vector<int> partition(vertexc, 0);
    find_cut(sink, source, partition, newcapac, edgeIndices, mf);
    for (int i = 0; i < vertexc; i++) {
      if (comp[i] == source && partition[i]) {
        comp[i] = sink;
        compsz[source]--;
        compsz[sink]++;
      }
    }
    vector<Edge> newedges;
    for (Edge e : tree_edges) {
      if (e.u == source) {
        if (partition[e.v]) {
          e.u = sink;
        }
      }
      if (e.v == source) {
        if (partition[e.u]) {
          e.v = sink;
        }
      }
      newedges.push_back(e);
    }
    newedges.push_back(Edge(source, sink, newWeight));
    tree_edges = newedges;
  }

 public:
  GomoryHu(int _vertexc) {
    vertexc = _vertexc;
    capac = vector<vector<int>>(vertexc, vector<int>(vertexc, 0));
    comp = vector<int>(vertexc, 0);
    compsz = vector<int>(vertexc, 0);
    compsz[0] = vertexc;
    tree_edges = vector<Edge>();
  }
  void set_capac(int u, int v, int w) {
    capac[u][v] = w;
    capac[v][u] = w;
  }
  vector<Edge> build_tree() {
    for (int i = 0; i < vertexc - 1; i++) {
      for (int j = 0; j < vertexc; j++) {
        if (compsz[j] >= 2) {
          split_component(j);
        }
      }
    }
    return tree_edges;
  }
};
bool operator<(Edge e, Edge f) {
  if (e.w != f.w) {
    return e.w < f.w;
  }
  return make_pair(e.u, e.v) < make_pair(f.u, f.v);
}
const int MAX_N = 205;
int root[MAX_N];
int find(int u) {
  if (u != root[u]) {
    root[u] = find(root[u]);
  }
  return root[u];
}
vector<int> path[MAX_N];
void merge(int u, int v) {
  u = find(u);
  v = find(v);
  root[u] = v;
  path[v].insert(path[v].end(), path[u].begin(), path[u].end());
}
int main() {
  int vertexc, edgec;
  cin >> vertexc >> edgec;
  for (int i = 0; i < vertexc; i++) {
    root[i] = i;
    path[i] = {i};
  }
  GomoryHu gh(vertexc);
  for (int i = 0; i < edgec; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    gh.set_capac(u, v, w);
  }
  vector<Edge> tree = gh.build_tree();
  sort(tree.rbegin(), tree.rend());
  int sum = 0;
  for (Edge e : tree) {
    sum += e.w;
    merge(e.u, e.v);
  }
  int root = find(0);
  cout << sum << endl;
  for (int u : path[root]) {
    cout << u + 1 << " ";
  }
  cout << endl;
}