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 JAVA):

Solution:
import java.util.*;

/*
6 9
0 1 1
0 2 7
1 2 1
1 3 3
1 4 2
2 4 4
3 4 1
3 5 6
4 5 2

6 11
0 1 10
0 5 8
1 2 4
1 4 2
1 5 3
2 3 5
2 4 4
2 5 2
3 4 7
3 5 2
4 5 3

 */

public class GomoryHuTree {
	public static int sum;
	public static void main(String[] args){
		Scanner br = new Scanner(System.in);
		int n = br.nextInt();
		int m = br.nextInt();
		ArrayList<Edge>[] g = new ArrayList[n];
		for(int i = 0;i<n;i++){
			g[i] = new ArrayList<Edge>();
		}
		
		
		for(int i = 0;i<m;i++){
			int s = br.nextInt()-1;
			int e = br.nextInt()-1;
			int cap = br.nextInt();
			g[s].add(new Edge(e, cap, -1));
		}
		
		GomoryHuTree gh = new GomoryHuTree(g);
		
		Edge[] es = gh.getCuts();
		
		ArrayList<Edge>[] cs = new ArrayList[n];
		for(int i = 0;i<n;i++){
			cs[i] = new ArrayList<Edge>();
		}
		
		for(int i = 0;i<n;i++){
			if(es[i] != null){
				cs[es[i].e].add(new Edge(i, es[i].cap, -1));
				//System.out.println(i+" "+es[i].e+" "+es[i].cap);
			}
		}
		sum = 0;
		ArrayList<Integer> order = getOrder(es, cs, new boolean[n], 0);
		System.out.println(sum);
		for(int i : order){
			System.out.print(i+" ");
		}
	}
	public static ArrayList<Integer> getOrder(Edge[] es, ArrayList<Edge>[] cs, boolean[] cut, int root){
		int min = 1000000000;
		int root1 = -1;
		int root2 = -1;
		
		boolean[] vis = new boolean[es.length];
		vis[root] = true;
		
		ArrayDeque<Integer> qu = new ArrayDeque<Integer>();
		qu.add(root);
		while(qu.size() > 0){
			int cur = qu.poll();
			
			if(!cut[cur] && es[cur] != null){
				if(!vis[es[cur].e]){
					vis[es[cur].e] = true;
					qu.add(es[cur].e);
					if(es[cur].cap < min){
						min = es[cur].cap;
						root1 = cur;
						root2 = es[cur].e;
					}
				}
			}
			
			for(Edge e : cs[cur]){
				if(!vis[e.e] && !cut[e.e]){
					vis[e.e]= true;
					qu.add(e.e);
					if(e.cap < min){
						min = e.cap;
						root1 = e.e;
						root2 = cur;
					}
				}
			}
			
		}
		if(root1 == -1){
			ArrayList<Integer> order = new ArrayList<Integer>();
			order.add(root+1);
			return order;
		}
		sum+=min;
		cut[root1] = true;
		ArrayList<Integer> res = getOrder(es, cs, cut, root1);
		res.addAll(getOrder(es, cs, cut, root2));
		
		return res;
	}
	ArrayList<Edge>[] g;
	int n;
	
	public GomoryHuTree(ArrayList<Edge>[] gg){
		g = gg;
		n = gg.length;
	}
	
	public Edge[] getCuts(){
		int[] parent = new int[n];
		int[][] answer = new int[n][n];
		for(int i = 0;i<n;i++){
			Arrays.fill(answer[i], 1000000);
		}
		
		for(int i = 1;i<n;i++){
			HashSet<Integer> cut = new HashSet<Integer>();
			int flow = 0;
			Dinic d = new Dinic(n, i, parent[i]);
			for(int j = 0;j<n;j++){
				for(Edge e : g[j]){
					d.add(j, e.e, e.cap);
				}
			}
			flow = d.maxFlow();
			
			boolean[] seen = new boolean[n];
			seen[i] = true;
			cut.add(i);
			ArrayDeque<Integer> qu = new ArrayDeque<Integer>();
			qu.add(i);
			while(qu.size() > 0){
				int cur = qu.poll();
				for(Edge e : d.g[cur]){
					if(e.flow < e.cap){
						if(!seen[e.e]){
							seen[e.e]= true;
							qu.add(e.e);
							cut.add(e.e);
						}
					}
				}
			}
			for(int j = i+1;j<n;j++){
				if(cut.contains(j) && parent[j] == parent[i]){
					parent[j] = i;
				}
			}
			answer[i][parent[i]] = answer[parent[i]][i] = flow;
			for(int j = 0;j<i;j++){
				answer[i][j] = answer[j][i] = Math.min(flow, answer[parent[i]][j]);
			}
		}
		Edge[] es = new Edge[n];
		for(int i = 0;i<n;i++){
			if(parent[i] != i)
				es[i] = new Edge(parent[i], answer[i][parent[i]], -1);
		}
		return es;
	}
	public static class Edge {
		int e, flow, rev, cap;
		public Edge(int b, int c, int f) {
			cap = c; e = b; rev = f;
		}
	}
	public class Dinic {
		ArrayList<Edge>[] gg;
		ArrayDeque<Integer> qu;
		Edge[][] g;
		int src, sink, n;
		int[] dist;
		boolean[] blocked;
		public Dinic(int N, int s, int t) {
			n = N; src = s; sink = t; //src = N++; sink = N++; n = N;
			g = new Edge[n][0];
			gg = new ArrayList[n];
			qu = new ArrayDeque<Integer>();
			for (int i = 0; i < n; gg[i] = new ArrayList<Edge>(),i++);
		}
		public void add(int s, int e, int cap) {
			gg[s].add(new Edge(e, cap, gg[e].size() + (s == e ? 1 : 0)));
			gg[e].add(new Edge(s, cap, gg[s].size() - 1));
		}
		public int maxFlow() {
			for(int i=0;i<n; i++)
				g[i] = gg[i].toArray(g[i]);
			int ans = 0;
			blocked = new boolean[n];
			while (bfs()){
				Arrays.fill(blocked, false);
				ans+=dfs(src, (int)2e9);
			}
			return ans;
		}
		public boolean bfs() {
			dist = new int[n];
			qu.add(sink);
			while(!qu.isEmpty() ){
				int cur = qu.poll();
				if(dist[src] != 0 && dist[cur] >= dist[src]) break;
				for(Edge e : g[cur])
					if(g[e.e][e.rev].flow < g[e.e][e.rev].cap && e.e != sink &&  dist[e.e] == 0){
						qu.add(e.e);
						dist[e.e] = dist[cur]+1;
					}
			}
			qu.clear();
			return (dist[src] != 0);
		}
		public int dfs(int pos, int min) {
			if (pos == sink) return min;
			int flow = 0;
			for (Edge e : g[pos])
				if (!blocked[e.e] && dist[e.e]+1 == dist[pos] && e.flow < e.cap) {
					int cur = dfs(e.e, Math.min(min-flow, e.cap-e.flow));
					g[e.e][e.rev].flow = -(e.flow += cur);
					flow+=cur;
					if(flow == min)
						return flow;
				}
			blocked[pos] |= (flow != min);
			return flow;
		}
	}
	
}