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 INF = 0x3f3f3f3f;
const int MAXV = 210;
struct Graph {
  struct Edge {
    int v, u;
    Edge(int _v, int _u) : v(_v), u(_u) {}
  };
  int n;
  vector<Edge> edges;
  vector<vector<int>> adj;
  Graph(int _n) : n(_n) { adj.resize(n); }
  void add_edge(int v, int w, int u) {
    adj[v].push_back(edges.size());
    edges.push_back(Edge(w, u));
    adj[w].push_back(edges.size());
    edges.push_back(Edge(v, u));
  }
};
vector<int> level;
bool bfs(Graph &g, int s, int t) {
  fill(level.begin(), level.end(), -1);
  level[s] = 0;
  queue<int> queue({s});
  while (!queue.empty()) {
    int v = queue.front();
    if (level[v] == level[t]) break;
    queue.pop();
    for (int i : g.adj[v]) {
      int w = g.edges[i].v, u = g.edges[i].u;
      if (level[w] == -1 && u > 0) {
        level[w] = level[v] + 1;
        queue.push(w);
      }
    }
  }
  return level[t] != -1;
}
vector<int> ptr;
int augment(Graph &g, int v, int t, int cap) {
  if (v == t) return cap;
  for (int &p = ptr[v]; p < (int)g.adj[v].size(); p++) {
    int i = g.adj[v][p];
    int w = g.edges[i].v, u = g.edges[i].u;
    if (level[w] == level[v] + 1 && u > 0) {
      int eps = augment(g, w, t, min(cap, u));
      if (eps > 0) {
        g.edges[i].u -= eps;
        g.edges[i ^ 1].u += eps;
        return eps;
      }
    }
  }
  return 0;
}
int maxflow(Graph &g, int s, int t) {
  level.resize(g.n), ptr.resize(g.n);
  int total_flow = 0, cur_flow;
  while (bfs(g, s, t)) {
    fill(ptr.begin(), ptr.end(), 0);
    do {
      cur_flow = augment(g, s, t, INF);
      total_flow += cur_flow;
    } while (cur_flow > 0);
  }
  return total_flow;
}
Graph gomory_hu(Graph &g) {
  vector<int> p(g.n, 0), cap(g.n);
  Graph original_g = g;
  for (int s = 1; s < g.n; s++) {
    int t = p[s];
    cap[s] = maxflow(g, s, t);
    vector<bool> in_cut(g.n, 0);
    queue<int> queue({s});
    in_cut[s] = true;
    while (!queue.empty()) {
      int v = queue.front();
      queue.pop();
      for (int i : g.adj[v]) {
        int w = g.edges[i].v, u = g.edges[i].u;
        if (u > 0 && !in_cut[w]) {
          in_cut[w] = true;
          queue.push(w);
        }
      }
    }
    for (int v = 0; v < g.n; v++)
      if (v != s && in_cut[v] && p[v] == t) p[v] = s;
    if (in_cut[p[t]]) {
      p[s] = p[t];
      p[t] = s;
      swap(cap[s], cap[t]);
    }
    g = original_g;
  }
  Graph tree(g.n);
  for (int v = 1; v < g.n; v++) tree.add_edge(v, p[v], cap[v]);
  return tree;
}
int sum_of_caps(const Graph &g) {
  int sum = 0;
  for (int v = 0; v < g.n; v++)
    for (int i : g.adj[v])
      if (g.edges[i].v > v) sum += g.edges[i].u;
  return sum;
}
inline void erase_from_list(vector<int> &v, int x) {
  v.erase(find(v.begin(), v.end(), x));
}
vector<int> solve(Graph &g, int v) {
  int lowest_cost = INF;
  int r = -1, edge_idx = -1;
  queue<int> queue({v});
  vector<bool> seen(g.n);
  seen[v] = 1;
  while (!queue.empty()) {
    int cur = queue.front();
    queue.pop();
    for (int i : g.adj[cur]) {
      int w = g.edges[i].v, u = g.edges[i].u;
      if (seen[w]) continue;
      if (u < lowest_cost) {
        lowest_cost = u;
        r = cur, edge_idx = i;
      }
      seen[w] = 1;
      queue.push(w);
    }
  }
  if (r == -1) return {v};
  erase_from_list(g.adj[r], edge_idx);
  erase_from_list(g.adj[g.edges[edge_idx].v], edge_idx ^ 1);
  vector<int> sol_r = solve(g, r);
  vector<int> sol_s = solve(g, g.edges[edge_idx].v);
  sol_r.insert(sol_r.end(), sol_s.begin(), sol_s.end());
  return sol_r;
}
int main() {
  int n, m;
  cin >> n >> m;
  Graph g(n);
  for (int i = 0; i < m; i++) {
    int v, w, u;
    scanf("%d%d%d", &v, &w, &u);
    g.add_edge(v - 1, w - 1, u);
  }
  Graph tree = gomory_hu(g);
  printf("%d\n", sum_of_caps(tree));
  vector<int> sol = solve(tree, 0);
  for (int v : sol) printf("%d ", v + 1);
  printf("\n");
  return 0;
}