#include using namespace std; const int maxn=3e3+10; int mp[maxn]; int main() { ios::sync_with_stdio(false); int n,m,u,v,w,minl; while(cin>>n>>m) { minl=1<<30; memset(mp,0,sizeof(mp)); for(int i=0;i>u>>v>>w; if(v!=u){ mp[v]+=w; mp[u]+=w; } } for(int i=1;i<=n;++i) minl=min(minl,mp[i]); cout<