#include <bits/stdc++.h>

using namespace std;
#define int long long
vector <pair <int, pair <int, int> > > G;
vector <pair <int, pair <int, int> > > Gdub;
vector <pair <int, int> > Gr[200010];
vector <int> parrent;
vector <int> runk;
int up[200010][20];
int lcost[200010][20];
int timer = 0;
vector <int> tin;
vector <int> tout;
void dfs(int v, int par, int co)
{
    tin[v] = ++timer;
    up[v][0] = par;
    lcost[v][0] = co;
    for (int i = 1; i < 20; i++)
    {
        int vv = up[v][i - 1];
        up[v][i] = up[vv][i - 1];
        lcost[v][i] = max(lcost[v][i - 1], lcost[vv][i - 1]);
    }
    for (auto to : Gr[v])
        if (to.first != par)
            dfs(to.first, v, to.second);
    tout[v] = ++timer;
}
bool is_upper(int low, int up)
{
    return (tin[up] <= tin[low] && tout[up] >= tout[low]);
}
int cost_l (int u, int v)
{
    int ans = max(lcost[u][0], lcost[v][0]);
    for (int i = 19; i >= 0; i--)
    {
        int uu = up[u][i];
        if (!is_upper(uu, v))
        {
            ans = max(ans, lcost[u][i]);
            u = uu;
        }
    }
    for (int i = 19; i >= 0; i--)
    {
        int vv = up[v][i];
        if (!is_upper(vv, u))
        {
            ans = max(ans, lcost[v][i]);
            v = vv;
        }
    }
    return ans;
}
int lca(int u, int v)
{
    if (is_upper(v, u))
        return u;
    for (int i = 19; i >= 0; i--)
    {
        int uu = up[u][i];
        if (!is_upper(v, uu))
        {
            u = uu;
        }
    }
    return up[u][0];
}
int find_set(int v)
{
    if (v == parrent[v])
        return v;
    return parrent[v] = find_set(parrent[v]);
}
void union_set(int a, int b)
{
    a = find_set(a);
    b = find_set(b);
    if (runk[a] < runk[b])
        swap(a, b);
    parrent[b] = a;
    runk[a] += b;
}
void make_set(int v)
{
    parrent[v] = v;
    runk[v] = 1;
}
signed main()
{
    int n, m;
    cin >> n >> m;
    tin.resize(n + 1);
    tout.resize(n + 1);
    parrent.resize(n + 1);
    runk.resize(n + 1);
    for (int i = 0; i < m; i++)
    {
        int q, q1, c;
        cin >> q >> q1 >> c;
        G.push_back({c, {q, q1}});
        Gdub.push_back({c, {q, q1}});
    }
    for (int i = 1; i <= n; i++)
    {
        make_set(i);
    }
    int cnt = 0;
    sort(G.begin(), G.end());
    for (int i = 0; i < m; i++)
    {
        int a = G[i].second.first, b = G[i].second.second;
        if (find_set(a) != find_set(b))
        {
            union_set(a, b);
            cnt += G[i].first;
            Gr[a].push_back({b, G[i].first});
            Gr[b].push_back({a, G[i].first});
        }
    }
    dfs(1, 1, 0);
  //  cout << "------" << endl;
    for (int i = 0; i < m; i++)
    {
        int acnt = cnt;
        acnt += Gdub[i].first;
        acnt -= cost_l(Gdub[i].second.first, Gdub[i].second.second);
        //cout << cost_l(G[i].second.first, G[i].second.second) << " " << G[i].second.first << " " << G[i].second.second << endl;
        cout << acnt << endl;
    }
    return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<ll,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][22];
ll mx[200100][22];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
}

ll lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	ll res=0;
	for(int i=0;i<20;i++)
		if((depth[a]-depth[b])>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%I64d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=0;
	mx[1][0]=0;
	dfs(1,0,1);
	for(int i=0;i<19;i++)
    	for(int a=1;a<=n;a++)
    	{
    		par[a][i+1]=par[par[a][i]][i];
    		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
    	}
	rep(i,m)
	{
		ll w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		ll res=lca(u,v);
		printf("%I64d\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<ll,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][22];
ll mx[200100][22];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
}

ll lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	int tmp=depth[a]-depth[b];
	ll res=0;
	for(int i=19;i>=0;i--)
		if(tmp>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%I64d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=1;
	mx[1][0]=0;
	dfs(1,0,1);
	for(int i=0;i<19;i++)
    	for(int a=1;a<=n;a++)
    	{
    		par[a][i+1]=par[par[a][i]][i];
    		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
    	}
	rep(i,m)
	{
		ll w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		ll res=lca(u,v);
		printf("%I64d\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<ll,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][22];
ll mx[200100][22];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
}

ll lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	ll res=0;
	for(int i=0;i<20;i++)
		if((depth[a]-depth[b])>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%I64d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=0;
	mx[1][0]=0;
	dfs(1,0,1);
	for(int a=1;a<=n;a++)
    	for(int i=0;i<19;i++)
    	{
    		par[a][i+1]=par[par[a][i]][i];
    		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
    	}
	rep(i,m)
	{
		ll w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		ll res=lca(u,v);
		printf("%I64d\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<int,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][20];
int mx[200100][20];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
	for(int i=0;i<19;i++)
	{
		par[a][i+1]=par[par[a][i]][i];
		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
	}
}

int lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	int tmp=depth[a]-depth[b];
	int res=0;
	for(int i=0;i<20;i++)
		if((depth[a]-depth[b])>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=0;
	mx[1][0]=0;
	dfs(1,0,0);
	rep(i,m)
	{
		int w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		int res=lca(u,v);
		printf("%lld\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<ll,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][20];
ll mx[200100][20];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
	for(int i=0;i<19;i++)
	{
		par[a][i+1]=par[par[a][i]][i];
		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
	}
}

ll lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	ll res=0;
	for(int i=0;i<20;i++)
		if((depth[a]-depth[b])>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%I64d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=0;
	mx[1][0]=0;
	dfs(1,0,0);
	rep(i,m)
	{
		ll w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		ll res=lca(u,v);
		printf("%I64d\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<int,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][20];
int mx[200100][20];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
	for(int i=1;i<20;i++)
	{
		par[a][i]=par[par[a][i-1]][i-1];
		mx[a][i]=max(mx[a][i-1],mx[par[a][i-1]][i-1]);
	}
}

int lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	int tmp=depth[a]-depth[b];
	int res=0;
	for(int i=19;i>=0;i--)
		if(tmp>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=1;
	mx[1][0]=0;
	dfs(1,0,0);
	rep(i,m)
	{
		int w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		int res=lca(u,v);
		printf("%lld\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<ll,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][22];
ll mx[200100][22];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
}

ll lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	int tmp=depth[a]-depth[b];
	ll res=0;
	for(int i=19;i>=0;i--)
		if(tmp>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=19;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%I64d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=0;
	mx[1][0]=0;
	dfs(1,0,1);
	for(int i=0;i<19;i++)
    	for(int a=1;a<=n;a++)
    	{
    		par[a][i+1]=par[par[a][i]][i];
    		mx[a][i+1]=max(mx[a][i],mx[par[a][i]][i]);
    	}
	rep(i,m)
	{
		ll w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		ll res=lca(u,v);
		printf("%I64d\n",ans-res+w);
	}
	return 0;
}


// author: hjy
// Problem:
#include<bits/stdc++.h>
//#pragma GCC optimize(2)
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define rep(i,n) for(register int i=0; i<(int)(n); ++i)
#define per(i,n) for(register int i=(int)(n)-1; i>=0; --i)
#define rep1(i,n) for(register int i=1; i<=(int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<"="<<x<<'\n'
template<typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }
inline int read() {
	int x=0,ng=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-') ng=1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return ng?-x:x;
}
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int seed=20040305;

int n,m;
vector<pair<int,pii> > V,ord;
vector<pii> vec[200100];
int fa[200100];
int par[200100][20];
int mx[200100][20];
int depth[200100];
ll ans=0;

int find(int a) { return fa[a]==a? a:fa[a] =find(fa[a]); }

void dfs(int a,int p,int d)
{
	depth[a]=d;
	rep(i,vec[a].size())
	{
		int u=vec[a][i].fi;
		int w=vec[a][i].se;
		if(u==p) continue;
		par[u][0]=a;
		mx[u][0]=w;
		dfs(u,a,d+1);
	}
	for(int i=1;i<19;i++)
	{
		par[a][i]=par[par[a][i-1]][i-1];
		mx[a][i]=max(mx[a][i-1],mx[par[a][i-1]][i-1]);
	}
}

int lca(int a,int b)
{
	if(depth[a]<depth[b]) swap(a,b);
	int tmp=depth[a]-depth[b];
	int res=0;
	for(int i=18;i>=0;i--)
		if(tmp>>i&1)
		{
			umax(res,mx[a][i]);
			a=par[a][i];
		}
	if(a==b) return res;
	for(int i=18;i>=0;i--)
		if(par[a][i]!=par[b][i])
		{
			umax(res,mx[a][i]);
			umax(res,mx[b][i]);
			a=par[a][i];
			b=par[b][i];
		}
	umax(res,mx[a][0]);
	umax(res,mx[b][0]);
	return res;
}

int main()
{
	scanf("%d%d",&n,&m);
	rep(i,m)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		V.pb(mp(w,mp(u,v)));
		ord.pb(mp(w,mp(u,v)));
	}
	sort(all(V));
	rep1(i,n) fa[i]=i;
	for(int i=0;i<m;i++)
	{
		int w=V[i].fi;
		int u=V[i].se.fi;
		int v=V[i].se.se;
		if(find(u)==find(v)) continue;
		vec[u].pb(mp(v,w));
		vec[v].pb(mp(u,w));
		u=find(u);
		v=find(v);
		fa[u]=v;
		ans+=w;
	}
	par[1][0]=1;
	mx[1][0]=0;
	dfs(1,1,0);
	rep(i,m)
	{
		int w=ord[i].fi;
		int u=ord[i].se.fi;
		int v=ord[i].se.se;
		int res=lca(u,v);
		printf("%lld\n",ans-res+w);
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int L = log2(N) + 10;

struct edge {
  int u, v, w, idx;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

int n, m;
int par[N], sz[N];
int anc[N][L];
int dp[N][L];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, int>> g[N];
long long mst;
long long ans[N];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  if (sz[pu] < sz[pv]) swap(pu, pv);
  sz[pu] += sz[pv];
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, int w) {
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = tim++;
  for (auto e : g[u]) {
    int v = e.first;
    int weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = tim++;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[v][i], u)) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  ret = max(ret, dp[v][0]);
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = -1;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == -1) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += (1LL) * weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  if (root != -1) dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int L = ceil(log2(N)) + 5;

struct edge {
  int u, v, w, idx;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

int n, m;
int par[N];
int anc[N][L];
int dp[N][L];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, int>> g[N];
long long mst;
long long ans[N];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, int w) {
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = ++tim;
  for (auto e : g[u]) {
    int v = e.first;
    int weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = ++tim;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[v][i], u)) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = -1;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == -1) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += (1LL) * weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct edge {
  int u, v, w, idx;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

const int N = 2e5 + 5;
const int L = log2(N) + 5;

int n, m;
int par[N], sz[N];
int anc[N][L];
int dp[N][L];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, int>> g[N];
long long mst;
long long ans[N];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  if (sz[pu] < sz[pv]) swap(pu, pv);
  sz[pu] += sz[pv];
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, int w) {
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = tim++;
  for (auto e : g[u]) {
    int v = e.first;
    int weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = tim++;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[v][i], u)) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  ret = max(ret, dp[v][0]);
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    sz[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = -1;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == -1) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  if (root != -1) dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int L = ceil(log2(N)) + 5;

struct edge {
  int u, v, w, idx;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

int n, m;
int par[N];
int anc[N][L];
int dp[N][L];
int depth[N];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, int>> g[N];
long long mst;
long long ans[N];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, int w) {
  depth[u] = 1 + depth[p];
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = ++tim;
  for (auto e : g[u]) {
    int v = e.first;
    int weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = ++tim;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (depth[u] <= depth[anc[v][i]]) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = -1;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == -1) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += (1LL) * weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int L = ceil(log2(N)) + 5;

struct edge {
  int u, v, idx;
  long long w;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

int n, m;
int par[N];
int anc[N][L];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, long long>> g[N];
long long mst;
long long ans[N];
long long dp[N][L];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, long long w) {
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = ++tim;
  for (auto e : g[u]) {
    int v = e.first;
    long long weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = ++tim;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[v][i], u)) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = 0;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == 0) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += (1LL) * weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;
const int L = ceil(log2(N)) + 5;

struct edge {
  int u, v, w, idx;
  bool operator < (const edge &x) {
    return (w < x.w);
  };
};

int n, m;
int par[N];
int anc[N][L];
int dp[N][L];
int depth[N];
int tin[N], tout[N], tim;
edge edges[N];
vector<pair<int, int>> g[N];
long long mst;
long long ans[N];

int fpar(int x) {
  return (par[x] == x ? x : par[x] = fpar(par[x]));
}

bool merge(int u, int v) {
  int pu = fpar(u);
  int pv = fpar(v);
  if (pu == pv) return false;
  par[pv] = pu;
  return true;
}

void dfs(int u, int p, int w) {
  depth[u] = 1 + depth[p];
  anc[u][0] = p;
  dp[u][0] = w;
  for (int i = 1; i < L; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    dp[u][i] = max(dp[u][i - 1], dp[anc[u][i - 1]][i - 1]);
  }
  tin[u] = ++tim;
  for (auto e : g[u]) {
    int v = e.first;
    int weight = e.second;
    if (v == p) continue;
    dfs(v, u, weight);
  }
  tout[u] = ++tim;
}

int is_anc(int u, int v) {
  return (tin[u] <= tin[v] && tout[u] >= tout[v]);
}

int LCA(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!is_anc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return anc[u][0];
}

int qr(int u, int v) {
  int ret = 0;
  for (int i = L - 1; i >= 0; i--) {
    if (depth[u] <= depth[anc[u][i]]) {
      ret = max(ret, dp[v][i]);
      v = anc[v][i];
    }
  }
  return ret;
}

int getz(int u, int v) {
  int w = LCA(u, v);
  return max(qr(w, u), qr(w, v));
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
  }
  for (int i = 1; i <= m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].idx = i;
  }
  sort(edges + 1, edges + 1 + m);
  int cnt_node = 0;
  vector<bool> in_mst(m + 1);
  int root = -1;
  for (int i = 1; i <= m; i++) {
    int node_u = edges[i].u;
    int node_v = edges[i].v;
    int weight = edges[i].w;
    if (merge(node_u, node_v)) {
      if (root == -1) root = node_u;
      g[node_u].push_back({node_v, weight});
      g[node_v].push_back({node_u, weight});
      mst += (1LL) * weight;
      cnt_node++;
      in_mst[edges[i].idx] = 1;
      if (cnt_node == n - 1) break;
    }
  }
  dfs(root, root, 0);
  for (int i = 1; i <= m; i++) {
    int id = edges[i].idx;
    if (in_mst[id]) {
      ans[id] = mst;
    } else {
      ans[id] = mst + (1LL) * (edges[i].w - getz(edges[i].u, edges[i].v));
    }
  }
  for (int i = 1; i <= m; i++) {
    cout << ans[i] << '\n';
  }

  return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<vector<int> > md;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;

	//premature optimization is the root of all evil:
	for (int i = 1; i <= l /*&& up[v][i - 1] > 0*/; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
		md[v][i] = max(md[v][i - 1], md[up[v][i - 1]][i - 1]); //nn
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		md[u][0] = g[v][j].second; //nn
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_max2(int a, int b) {
	int c = a;
	int j = 0;

	int mx = numeric_limits<int>::min();
	while (c != b) {
		int t = up[c][j];
		if (upper(b, t)) {
			mx = max(mx, md[c][j]);
			j++;
			if (t == b)
				break;
		}
		else {
			c = up[c][j - 1];
		}
	}
	return mx;
}

int get_max(int a, int b) {
	int u = a;
	int i = l;

	int mx = numeric_limits<int>::min();
	if (a == b) {
		return mx;
	}
	do {
		if (!upper(up[u][i], b)) {
			mx = max(mx, md[u][i]);
			u = up[u][i];
		}
		--i;
	} while (i >= 0);
	return max(mx, md[u][0]);
}

pair<int,int> lca(int a, int b) {
	int res = 0;
	if (upper(a, b)) {
		res = a;
	}
	else if (upper(b, a))
		res = b;
	else {
		int u = a;
		int i = l;

		do {
			if (!upper(up[u][i], b))
				u = up[u][i];
			--i;
		} while (i >= 0);
		res = up[u][0];
	}
	int mx = max(get_max(a, res), get_max(b, res));
	return { res, mx };
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	md.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i) {
		up[i].resize(l + 1);
		md[i].resize(l + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc, mx;
			tie(lc, mx) = lca(u, v);
			//ll mx = numeric_limits<ll>::min();
			//from u to lc
			/*
			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}
			*/
			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<vector<int> > md;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;

	for (int i = 1; i <= l && up[v][i - 1] > 0; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
		md[v][i] = max(md[v][i - 1], md[up[v][i - 1]][i - 1]); //nn
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		md[u][0] = g[v][j].second; //nn
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_max(int a, int b) {
	int c = a;
	int j = 0;

	int mx = numeric_limits<int>::min();
	while (c != b) {
		int t = up[c][j];
		if (upper(b, t)) {
			mx = max(mx, md[c][j]);
			j++;
			if (t == b)
				break;
		}
		else {
			c = up[c][j - 1];
		}
	}
	return mx;
}

pair<int,int> lca(int a, int b) {
	int res = 0;
	if (upper(a, b)) {
		res = a;
	}
	else if (upper(b, a))
		res = b;
	else {
		int u = a;
		int i = l;

		do {
			if (!upper(up[u][i], b))
				u = up[u][i];
			--i;
		} while (i >= 0);
		res = up[u][0];
	}
	int mx = max(get_max(a, res), get_max(b, res));
	return { res, mx };
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	md.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i) {
		up[i].resize(l + 1);
		md[i].resize(l + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc, mx;
			tie(lc, mx) = lca(u, v);
			//ll mx = numeric_limits<ll>::min();
			//from u to lc
			/*
			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}
			*/
			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

int mst_kruskal() {
	int sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;
	for (int i = 1; i <= l && up[v][i - 1] > 0; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca(int a, int b) {
	if (upper(a, b))
		return a;
	if (upper(b, a))
		return b;

	int u = a;
	int i = l;
	do {
		if (!upper(up[u][i], b))
			u = up[u][i];
		--i;
	} while (i >= 0);
	return up[u][0];
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i)  up[i].resize(l + 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc = lca(u, v);
			ll mx = numeric_limits<ll>::min();
			//from u to lc

			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}

			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<vector<int> > md;
vector<int> vh;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;

	//premature optimization is the root of all evil:
	for (int i = 1; i <= l /*&& up[v][i - 1] > 0*/; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
		md[v][i] = max(md[v][i - 1], md[up[v][i - 1]][i - 1]);
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		md[u][0] = g[v][j].second;
		vh[u] = vh[v] + 1;
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_best(int v, int span)
{
	int ret = numeric_limits<int>::min();
	for (int i = l; i >= 0; --i)
	{
		if (span&(1 << i))
		{
			ret = max(ret, md[v][i]);
			v = up[v][i];
		}
	}
	return ret;
}

int lca(int a, int b) {
	if (upper(a, b))
		return a;

	if (upper(b, a))
		return b;

	int u = a;
	int i = l;

	do {
		if (!upper(up[u][i], b))
			u = up[u][i];
		--i;
	} while (i >= 0);
	return up[u][0];
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	md.resize(n);
	vh.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i) {
		up[i].resize(l + 1);
		md[i].resize(l + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc, mx;
			lc = lca(u, v);
			mx = max(get_best(u, vh[u] - vh[lc]), get_best(v, vh[v] - vh[lc]));

			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<vector<int> > md;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;

	//premature optimization is the root of all evil:
	for (int i = 1; i <= l /*&& up[v][i - 1] > 0*/; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
		md[v][i] = max(md[v][i - 1], md[up[v][i - 1]][i - 1]); //nn
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		md[u][0] = g[v][j].second; //nn
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_max(int a, int b) {
	int c = a;
	int j = 0;

	int mx = numeric_limits<int>::min();
	while (c != b) {
		int t = up[c][j];
		if (upper(b, t)) {
			mx = max(mx, md[c][j]);
			j++;
			if (t == b)
				break;
		}
		else {
			c = up[c][j - 1];
		}
	}
	return mx;
}

pair<int,int> lca(int a, int b) {
	int res = 0;
	if (upper(a, b)) {
		res = a;
	}
	else if (upper(b, a))
		res = b;
	else {
		int u = a;
		int i = l;

		do {
			if (!upper(up[u][i], b))
				u = up[u][i];
			--i;
		} while (i >= 0);
		res = up[u][0];
	}
	int mx = max(get_max(a, res), get_max(b, res));
	return { res, mx };
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	md.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i) {
		up[i].resize(l + 1);
		md[i].resize(l + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc, mx;
			tie(lc, mx) = lca(u, v);
			//ll mx = numeric_limits<ll>::min();
			//from u to lc
			/*
			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}
			*/
			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<vector<int> > md;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;

	//premature optimization is the root of all evil:
	for (int i = 1; i <= l /*&& up[v][i - 1] > 0*/; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
		md[v][i] = max(md[v][i - 1], md[up[v][i - 1]][i - 1]); //nn
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		md[u][0] = g[v][j].second; //nn
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int get_max2(int a, int b) {
	int c = a;
	int j = 0;

	int mx = numeric_limits<int>::min();
	while (c != b) {
		int t = up[c][j];
		if (upper(b, t)) {
			mx = max(mx, md[c][j]);
			j++;
			if (t == b)
				break;
		}
		else {
			c = up[c][j - 1];
		}
	}
	return mx;
}

int get_max(int a, int b) {
	int u = a;
	int i = l;

	int mx = numeric_limits<int>::min();
	do {
		if (!upper(up[u][i], b)) {
			mx = max(mx, md[u][i]);
			u = up[u][i];
		}
		--i;
	} while (i >= 0);
	return max(mx, md[u][0]);
}

pair<int,int> lca(int a, int b) {
	int res = 0;
	if (upper(a, b)) {
		res = a;
	}
	else if (upper(b, a))
		res = b;
	else {
		int u = a;
		int i = l;

		do {
			if (!upper(up[u][i], b))
				u = up[u][i];
			--i;
		} while (i >= 0);
		res = up[u][0];
	}
	int mx = max(get_max(a, res), get_max(b, res));
	return { res, mx };
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	md.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i) {
		up[i].resize(l + 1);
		md[i].resize(l + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc, mx;
			tie(lc, mx) = lca(u, v);
			//ll mx = numeric_limits<ll>::min();
			//from u to lc
			/*
			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}
			*/
			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

class dsu
{
public:
	dsu(int n);
	void reinit_dsu(int n);
	void make(int r);
	int find(int elem);
	int unite(int s1, int s2);
private:
	std::vector<int> parent;
	std::vector<int> rank;
};

dsu::dsu(int n)
{
	reinit_dsu(n);
}

void dsu::reinit_dsu(int n)
{
	parent.resize(n);
	rank.resize(n);
}

void dsu::make(int r)
{
	parent[r] = r;
	rank[r] = 1;
}

int dsu::find(int elem)
{
	if (parent[elem] == elem)
		return elem;
	parent[elem] = find(parent[elem]);
	return parent[elem];
}

int dsu::unite(int s1, int s2)
{
	s1 = find(s1);
	s2 = find(s2);

	//from s1 to s2
	if (rank[s2] < rank[s1])
		std::swap(s1, s2);

	parent[s1] = s2;
	if (rank[s1] == rank[s2])
		rank[s2]++;
	return s2;
}

int n;
vector<vector<pair<int, int>> > g;
vector<tuple<int, int, int, ll>> edges;
vector<ll> sums;
vector<int> ids;
vector<int> ans;

ll mst_kruskal() {
	ll sum = 0;
	//sort edges
	sort(begin(edges), end(edges), [](const tuple<int, int, int, ll>& a, const tuple<int, int, int, ll>& b) { return get<3>(a) < get<3>(b); });

	dsu d(n);
	for (int i = 0; i < n; i++)
	{
		d.make(i);
	}

	for (int i = 0; i < edges.size(); i++) {
		int j, u, v, w;
		tie(j, u, v, w) = edges[i];

		if (d.find(u) != d.find(v)) {
			d.unite(u, v);
			ans.push_back(j);
			sum += w;
		}

		ids[j] = i;
	}

	for (int i = 0; i < ans.size(); i++)
	{
		sums[ans[i]] = sum;
	}
	return sum;
}

int l;
vector<int> tin, tout;
vector<vector<int> > up;
vector<ll> pw;
int timer = 0;

void bl_dfs(int v, int p = 0) {
	tin[v] = ++timer;

	up[v][0] = p;
	for (int i = 1; i <= l && up[v][i - 1] > 0; ++i) {
		up[v][i] = up[up[v][i - 1]][i - 1];
	}

	for (int j = 0; j < g[v].size(); ++j) {
		int u = g[v][j].first;
		if (u == p)
			continue;

		pw[u] = g[v][j].second;
		bl_dfs(u, v);
	}
	tout[v] = ++timer;
}

bool upper(int a, int b) {
	return tin[a] <= tin[b] && tout[a] >= tout[b];
}

int lca(int a, int b) {
	if (upper(a, b))
		return a;
	if (upper(b, a))
		return b;

	int u = a;
	int i = l;
	do {
		if (!upper(up[u][i], b))
			u = up[u][i];
		--i;
	} while (i >= 0);
	return up[u][0];
}

void init_lca(int n) {
	tin.resize(n), tout.resize(n), up.resize(n);
	l = 1;
	while ((1 << l) <= n)  ++l;
	for (int i = 0; i < n; ++i)  up[i].resize(l + 1);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int m;
	cin >> n >> m;

	g.resize(n);

	sums.resize(m, -1);
	edges.resize(m);
	ids.resize(m);
	for (int i = 0; i < m; i++)
	{
		int u, v;
		ll w;
		cin >> u >> v >> w;
		u--;
		v--;

		edges[i] = {i, u, v, w};
	}

	init_lca(n);

	ll s = mst_kruskal();

	pw.resize(n);

	int root = get<1>(edges[ids[ans[0]]]);
	for (int i = 0; i < ans.size(); i++)
	{
		int j, u, v;
		ll w;
		tie(j, u, v, w) = edges[ids[ans[i]]];

		g[u].push_back({ v,w });
		g[v].push_back({ u, w });
	}

	bl_dfs(0);

	for (int i = 0; i < m; i++)
	{
		if (sums[i] == -1) {
			int j, u, v, w;
			tie(j, u, v, w) = edges[ids[i]];

			int lc = lca(u, v);
			ll mx = numeric_limits<ll>::min();
			//from u to lc

			int p = u;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			};

			p = v;
			while (p != lc) {
				if (pw[p] > mx) {
					mx = pw[p];
				}
				p = up[p][0];
			}

			sums[i] = s + w - mx;
		}
	}

	for (int i = 0; i < sums.size(); i++)
	{
		cout << sums[i] << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	if(x==y)return x;
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    	sz[i]=1;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<lc;
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],sz[N];
map<int,int> msp;
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<32;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<32;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y && x!=-1){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    // int q;
    // cin>>q;
    // while(q--){
    // 	int x,y;
    // 	cin>>x>>y;
    // 	cout<<lca(x,y)<<endl;
    // }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<"invalid lca!";
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int l;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int d=0;
int timer;
vector<int> tin, tout;
vector<vector<int>> up,mx;

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int v, int p){
	d++;
    tin[v] = ++timer;
    up[v][0] = p;
    if(v!=p){
    	mx[v][0]=ew[mp(v,p)];
    }
    for (int i = 1; i <= l; ++i){
    	up[v][i] = up[up[v][i-1]][i-1];
    	mx[v][i] = max(mx[v][i-1],mx[up[v][i-1]][i-1]);
    }
    for (int u : adj[v]) {
        if (u != p)dfs(u, v);
    }
    dep[v]=d;
    tout[v] = ++timer;
    d--;
}

bool is_ancestor(int u, int v){
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v){
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

void preprocess(int root) {
    tin.resize(N);
    tout.resize(N);
    timer = 0;
    l = ceil(log2(N));
    up.assign(N, vector<int>(l + 1));
    mx.assign(N, vector<int>(l + 1));
    dfs(root, root);
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=up[x][i];
		}
	}
	return ans;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    	sz[i]=1;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    preprocess(1);
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		cout<<res<<endl;
    	}else{
    		int lc=lca(ed[i].u,ed[i].v);
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=0,res2=0;
    		if(x1>0)res1=go2(ed[i].u,x1);
    		if(x2>0)res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y && x!=-1){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    	sz[i]=1;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<"invalid lca!";
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],size[N];
map<int,int> msp;
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (size[a] < size[b]) swap(a,b);
        size[a] += size[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<32;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<32;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y && x!=-1){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    // int q;
    // cin>>q;
    // while(q--){
    // 	int x,y;
    // 	cin>>x>>y;
    // 	cout<<lca(x,y)<<endl;
    // }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<"invalid lca!";
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y && x!=-1){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<"invalid lca!";
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
const int lim=log2(N)+5;
int lift[N][lim],mx[N][lim];

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int s, int e) {
	d++;
	for (auto u : adj[s]) {
		if (u != e) dfs(u, s);
	}
	par[s]=e;
	dep[s]=d;
	d--;
}

int go(int x,int k){
	//dg3(x,k,lift[5][0]);
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			x=lift[x][i];
		}
	}
	return x;
}

int go2(int x,int k){
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=lift[x][i];
		}
	}
	return ans;
}

bool check(int mid,int x,int y){
	x=go(x,mid);
	y=go(y,mid);
	if(x==y){
		return true;
	}else{
		return false;
	}
}

int lca(int x,int y){
	if(dep[y]>dep[x])swap(x,y);
	//dg4(x,dep[x],y,dep[y]);
	if(dep[x]>dep[y])x=go(x,abs(dep[x]-dep[y]));
	//dg2(x,y);
	int l=0,r=N,mid,ans;
	while(l<=r){
		mid=(l+r)/2;
		if(check(mid,x,y)){
			ans=mid;
			r=mid-1;
		}else{
			l=mid+1;
		}
	}
	if(ans>0)x=go(x,ans);
	return x;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    	sz[i]=1;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    dfs(1,0);
    for(int i=n;i>0;i--){
    	lift[i][0]=par[i];
    	mx[i][0]=ew[mp(i,par[i])];
    }
    for(int x=n;x>0;x--){
    	for(int j=1;j<lim;j++){
    		lift[x][j]=lift[lift[x][j-1]][j-1];
    		mx[x][j]=max(mx[x][j-1],mx[lift[x][j-1]][j-1]);
    	}
    }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		if(lc<=0){
    			cout<<"invalid lca!";
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		int res1=go2(ed[i].u,x1);
    		int res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}


#include<bits/stdc++.h>
#define int long long
#define pb emplace_back
#define mp make_pair
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define revrep(i,n) for(long long i=n-1;i>=0;i--)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator<int> output (cout," ")
#define pv(x) copy(all(x),output)
#define pa(a) rep(i,0,sizeof(a)/sizeof(a[0]))cout<<a[i]<<" "
#define endl '\n'
#define f first
#define s second
#define PI 3.141592653589793
#define set0(x) memset(x,0,sizeof(x))
#define set1(x) memset(x,1,sizeof(x))
#define getarr(arr,n) int arr[n];rep(i,0,n)cin>>a[i]
#define getvec(vec,n) vi vec;int x;rep(i,0,n){cin>>x;vec.pb(x);}
#define sort_uniq(c) (sort(c.begin(), c.end()), c.resize(distance(c.begin(), unique(c.begin(), c.end()))))
#define uniq(a) a.resize(distance(a.begin(), unique(a.begin(), a.end())))
#define dg(x) cout<<#x<<':'<<x<<endl;
#define dg2(x,y) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cout<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
int isPowerof2(int x) { return (x && !(x & x-1)); }

struct edge{
	int id;
	int u,v,w;
};

const int N=2e5+10;
int l;
int link[N],sz[N];
int msp[N];
map<ii,int> ew;
vi adj[N];
int dep[N];
int par[N];
int d=0;
//const int lim=log2(N)+5;
//int lift[N][lim],mx[N][lim];
int timer;
vector<int> tin, tout;
vector<vector<int>> up,mx;

int find(int x) {
    while (x != link[x]) x = link[x];
    return x;
}
bool same(int a, int b) {
    return find(a) == find(b);
}
void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a!=b){
        if (sz[a] < sz[b]) swap(a,b);
        sz[a] += sz[b];
        link[b] = a;
    }
}

bool cmp(edge a,edge b){
	if(a.w==b.w){
		return a.id < b.id;
	}else{
		return a.w < b.w;
	}
}

bool cmp2(edge a, edge b){
	return a.id < b.id;
}

void dfs(int v, int p){
	d++;
    tin[v] = ++timer;
    up[v][0] = p;
    if(v!=p){
    	mx[v][0]=ew[mp(v,p)];
    }
    for (int i = 1; i <= l; ++i){
    	up[v][i] = up[up[v][i-1]][i-1];
    	mx[v][i] = max(mx[v][i-1],mx[up[v][i-1]][i-1]);
    }

    for (int u : adj[v]) {
        if (u != p)dfs(u, v);
    }
    dep[v]=d;
    tout[v] = ++timer;
    d--;
}

bool is_ancestor(int u, int v){
    return tin[u] <= tin[v] && tout[u] >= tout[v];
}

int lca(int u, int v){
    if (is_ancestor(u, v))
        return u;
    if (is_ancestor(v, u))
        return v;
    for (int i = l; i >= 0; --i) {
        if (!is_ancestor(up[u][i], v))
            u = up[u][i];
    }
    return up[u][0];
}

void preprocess(int root) {
    tin.resize(N);
    tout.resize(N);
    timer = 0;
    l = ceil(log2(N));
    up.assign(N, vector<int>(l + 1));
    mx.assign(N, vector<int>(l + 1));
    dfs(root, root);
}

int go2(int x,int k){
	//dg2(x,mx[x][0]);
	int ans=0;
	for(int i=0;i<23;i++){
		if(k&(1<<i)){
			ans=max(ans,mx[x][i]);
			x=up[x][i];
		}
	}
	return ans;
}

int32_t main(){
    boost;
    for(int i=0;i<N;i++){
    	link[i]=i;
    	sz[i]=1;
    }
    int n,m;
    cin>>n>>m;
    edge ed[m];
    rep(i,0,m){
    	ed[i].id=i;
    	cin>>ed[i].u>>ed[i].v>>ed[i].w;
    	ew[mp(ed[i].u,ed[i].v)]=ed[i].w;
    	ew[mp(ed[i].v,ed[i].u)]=ed[i].w;
    }
    sort(ed,ed+m,cmp);
    int res=0;
    for(int i=0;i<m;i++){
    	if(!same(ed[i].u,ed[i].v)){
    		msp[ed[i].id]++;
    		unite(ed[i].u,ed[i].v);
    		res+=ed[i].w;
    		adj[ed[i].u].pb(ed[i].v);
    		adj[ed[i].v].pb(ed[i].u);
    	}
    }
    preprocess(1);
    // for(int i=n;i>0;i--){
    // 	mx[i][0]=ew[mp(i,par[i])];
    // }
    // for(int x=n;x>0;x--){
    // 	for(int j=1;j<=l;j++){
    // 		//lift[x][j]=lift[lift[x][j-1]][j-1];
    // 		mx[x][j]=max(mx[x][j-1],mx[up[x][j-1]][j-1]);
    // 	}
    // }
    sort(ed,ed+m,cmp2);
    for(int i=0;i<m;i++){
    	if(msp[ed[i].id]){
    		//cout<<"In msp:";
    		cout<<res<<endl;
    	}else{
    		//cout<<"Not in msp:";
    		int lc=lca(ed[i].u,ed[i].v);
    		//dg3(ed[i].u,ed[i].v,lc);
    		if(lc<=0){
    			cout<<lc;
    			return 0;
    		}
    		int x1=dep[ed[i].u]-dep[lc];
    		int x2=dep[ed[i].v]-dep[lc];
    		//dg2(x1,x2);
    		int res1=0,res2=0;
    		if(x1>0)res1=go2(ed[i].u,x1);
    		if(x2>0)res2=go2(ed[i].v,x2);
    		int res3=max(res1,res2);
    		//dg3(res1,res2,res3);
    		cout<<res+ed[i].w-res3<<endl;
    	}
    }
    return 0;
}