宝藏
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define U(i,u) for(register int i=head[u];i;i=nxt[i])
#define rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define per(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> PII;
typedef vector<int> VI;
template<class T> inline void read(T &x){
x=0;char c=getchar();int f=1;
while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
while(isdigit(c)){x=x*10+c-'0';c=getchar();}x*=f;
}
template<class T> inline void cmin(T &x, T y){x=x<y?x:y;}
template<class T> inline void cmax(T &x, T y){x=x>y?x:y;}
const int N=20;
const int INF=0x3f3f3f3f;
int n,m,g[N][N],dp[1<<13],dis[N];
int ans=INF;
void solve(int mask){
rep(i,1,n){
if(!((1<<(i-1))&mask))continue;
rep(j,1,n){
if((1<<(j-1))&mask)continue;
if(g[i][j]==INF)continue;
if(dp[mask|(1<<(j-1))]>dp[mask]+dis[i]*g[i][j]){
dis[j]=dis[i]+1;
dp[mask|(1<<(j-1))]=dp[mask]+dis[i]*g[i][j];
solve(mask|(1<<(j-1)));
}
}
}
}
int main(){
memset(g,0x3f,sizeof(g));read(n);read(m);rep(i,1,m){int a,b,c;read(a);read(b);read(c);g[a][b]=min(g[a][b],c);g[b][a]=g[a][b];}
rep(i,1,n)g[i][i]=0;
rep(i,1,n){
memset(dp,0x3f,sizeof(dp));
memset(dis,0,sizeof(dis));
dp[1<<(i-1)]=0;
dis[i]=1;
solve(1<<(i-1));
cmin(ans,dp[(1<<n)-1]);
}
printf("%d",ans);
return 0;
}