#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  assert(e2.size()==m);
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  auto cl=clock();
  auto timer=cl;
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 1\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  auto cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
  }
  fore(i,0,n)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    auto timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>1.9) {
      printf("DEMETRIO\n");
      return 0;
    }
  }
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(ufSz[y]>ufSz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>1.5) {
      printf("4FANTASTICOS\n");
      exit(0);
    }
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  for(int i=K-1;i>=0;i--)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
  }
  fore(i,0,n)ufPa[i]=i,ufSz[i]=1;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:e2)printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
vector<edge>edges;
set<pair<int,int>>mst;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    if(join(it.u,it.v)) {
      g[it.u].pb({it.cst,it.v});
      g[it.v].pb({it.cst,it.u});
      if(it.u>it.v)swap(it.u,it.v);
      mst.insert({it.u,it.v});
      res+=it.cst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,N)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    if(c[i-1][pa[i-1][x]])c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int lca(int x,int y) {
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])x=pa[i][x];
  if(x==y)return x;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y])x=pa[i][x],y=pa[i][y];
  return pa[0][x];
}
ll cost(int x,int paX) {
  ll res=0;
  rfor(i,K,0)if(d[x]-(1<<i)>=d[paX]) {
    res+=c[i][x];
    x=pa[i][x];
  }
  return res;
}
void debug() {
  cout<<"pa: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<pa[j][i]<<" ";cout<<endl;}
  cout<<"cost: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<c[j][i]<<" ";cout<<endl;}
  cout<<"t: "<<t<<endl;
  fore(i,0,n){cout<<i+1<<" : ";for(auto j:g[i])cout<<"{"<<j.snd+1<<","<<j.fst<<"} ";cout<<endl;}
  cout<<"mst: ";for(auto it:mst)cout<<"{"<<it.fst+1<<","<<it.snd+1<<"} ";cout<<endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin>>n>>m;
  fore(i,0,m) {
    int u,v;ll w;
    cin>>u>>v>>w;u--,v--;
    edges.pb(edge(u,v,w,i));
  }
  fore(i,0,N)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:edges) {
    int x=it.u,y=it.v;
    if(x>y)swap(x,y);
    ll res=t;
    if(!mst.count({x,y})) {
      res+=it.cst;
      int l=lca(x,y);ll mx=0;
      rfor(i,K,0)if(d[x]-(1<<i)>=d[l])mx=max(mx,c[i][x]),x=pa[i][x];
      rfor(i,K,0)if(d[y]-(1<<i)>=d[l])mx=max(mx,c[i][y]),y=pa[i][y];
      res-=mx;
    }
    // cout<<"{"<<it.snd.fst+1<<","<<it.snd.snd+1<<"} ("<<it.fst<<"): "<<t<<" "<<mx<<" : "<<res<<" "<<res<<endl;
    r[it.id]=res;
  }
  fore(i,0,m)cout<<r[i]<<"\n";
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 9\n");
      return 0;
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 7\n");
      return 0;
    }
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 8\n");
      return 0;
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      x=pa[i][x],y=pa[i][y];
    }
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=19,N=1<<19;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

struct edge {
  ll cst;
  int u,v,id;
  bool in=0;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
vector<edge>edges;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    if(join(it.u,it.v)) {
      g[it.u].pb({it.cst,it.v});
      g[it.v].pb({it.cst,it.u});
      if(it.u>it.v)swap(it.u,it.v);
      (&it)->in=1;
      res+=it.cst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,N)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    if(c[i-1][pa[i-1][x]])c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int lca(int x,int y) {
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])x=pa[i][x];
  if(x==y)return x;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y])x=pa[i][x],y=pa[i][y];
  return pa[0][x];
}
void debug() {
  cout<<"pa: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<pa[j][i]<<" ";cout<<endl;}
  cout<<"cost: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<c[j][i]<<" ";cout<<endl;}
  cout<<"t: "<<t<<endl;
  fore(i,0,n){cout<<i+1<<" : ";for(auto j:g[i])cout<<"{"<<j.snd+1<<","<<j.fst<<"} ";cout<<endl;}
  cout<<"edges: "<<endl;for(auto it:edges)cout<<it.u<<" "<<it.v<<" "<<it.cst<<" "<<it.id<<" "<<it.in<<endl;
}

int main() {
  // auto cl=clock();freopen("out","w",stdout);
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m;
  fore(i,0,m) {
    int u,v;ll w;
    cin>>u>>v>>w;u--,v--;
    edges.pb(edge(u,v,w,i));
  }
  fore(i,0,N)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:edges) {
    int x=it.u,y=it.v;
    if(x>y)swap(x,y);
    ll res=t;
    if(!it.in) {
      res+=it.cst;
      int l=lca(x,y);ll mx=0;
      rfor(i,K,0)if(d[x]-(1<<i)>=d[l])mx=max(mx,c[i][x]),x=pa[i][x];
      rfor(i,K,0)if(d[y]-(1<<i)>=d[l])mx=max(mx,c[i][y]),y=pa[i][y];
      res-=mx;
    }
    // cout<<"{"<<it.snd.fst+1<<","<<it.snd.snd+1<<"} ("<<it.fst<<"): "<<t<<" "<<mx<<" : "<<res<<" "<<res<<endl;
    r[it.id]=res;
  }
  fore(i,0,m)cout<<r[i]<<"\n";
  // cout<<"time: "<<(clock()-cl)*1./CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  auto cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
  }
  fore(i,0,n)ufPa[i]=i;
  t=kruskal();
  lca_init();
  auto timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  // printf("t: %f\n",timer);
  if(timer>1.5){printf("DEMETRIO\n");return 0;}
  // debug();
  for(auto it:e2)printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
vector<edge>edges;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    if(join(it.u,it.v)) {
      g[it.u].pb({it.cst,it.v});
      g[it.v].pb({it.cst,it.u});
      res+=it.cst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    if(c[i-1][pa[i-1][x]])c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  auto cl=clock();freopen("out","w",stdout);
  // ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  scanf("%d%d",&n,&m);
  // cin>>n>>m;
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    // cin>>u>>v>>w;u--,v--;
    edges.pb(edge(u,v,w,i));
  }
  fore(i,0,N)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:edges)r[it.id]=t+it.cst-query(it.u,it.v);
  fore(i,0,m)printf("%lld\n",r[i]);
  // fore(i,0,m)cout<<r[i]<<"\n";
  printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
  // cout<<"time: "<<(clock()-cl)*1./CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  assert(e2.size()==m);
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  rfor(i,K,0){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=19,N=1<<19;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

struct edge {
  ll cst;
  int u,v,id;
  bool in=0;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
vector<edge>edges;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    if(join(it.u,it.v)) {
      g[it.u].pb({it.cst,it.v});
      g[it.v].pb({it.cst,it.u});
      if(it.u>it.v)swap(it.u,it.v);
      (&it)->in=1;
      res+=it.cst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,N)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    if(c[i-1][pa[i-1][x]])c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int lca(int x,int y) {
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])x=pa[i][x];
  if(x==y)return x;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y])x=pa[i][x],y=pa[i][y];
  return pa[0][x];
}
void debug() {
  cout<<"pa: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<pa[j][i]<<" ";cout<<endl;}
  cout<<"cost: "<<endl;
  fore(i,0,n){cout<<i+1<<" : ";fore(j,0,n)cout<<c[j][i]<<" ";cout<<endl;}
  cout<<"t: "<<t<<endl;
  fore(i,0,n){cout<<i+1<<" : ";for(auto j:g[i])cout<<"{"<<j.snd+1<<","<<j.fst<<"} ";cout<<endl;}
  cout<<"edges: "<<endl;for(auto it:edges)cout<<it.u<<" "<<it.v<<" "<<it.cst<<" "<<it.id<<" "<<it.in<<endl;
}

int main() {
  // auto cl=clock();freopen("out","w",stdout);
  ios::sync_with_stdio(false);
  cin>>n>>m;
  fore(i,0,m) {
    int u,v;ll w;
    cin>>u>>v>>w;u--,v--;
    edges.pb(edge(u,v,w,i));
  }
  fore(i,0,N)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:edges) {
    int x=it.u,y=it.v;
    if(x>y)swap(x,y);
    ll res=t;
    if(!it.in) {
      res+=it.cst;
      int l=lca(x,y);ll mx=0;
      rfor(i,K,0)if(d[x]-(1<<i)>=d[l])mx=max(mx,c[i][x]),x=pa[i][x];
      rfor(i,K,0)if(d[y]-(1<<i)>=d[l])mx=max(mx,c[i][y]),y=pa[i][y];
      res-=mx;
    }
    // cout<<"{"<<it.snd.fst+1<<","<<it.snd.snd+1<<"} ("<<it.fst<<"): "<<t<<" "<<mx<<" : "<<res<<" "<<res<<endl;
    r[it.id]=res;
  }
  fore(i,0,m)cout<<r[i]<<"\n";
  // cout<<"time: "<<(clock()-cl)*1./CLOCKS_PER_SEC<<endl;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>1.5) {
      printf("4FANTASTICOS\n");
      exit(0);
    }
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  for(int i=K-1;i>=0;i--)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
  }
  fore(i,0,n)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:e2)printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define rfor(i,ii,iii) for(int i=ii-1;i>=iii;i--)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
/*
struct edge {
  ll cst;
  int u,v,id;
  edge(int u,int v,ll cst,int id):u(u),v(v),cst(cst),id(id){}
  bool operator<(const edge &b)const{return cst<b.cst;}
};
*/
vector<edge>edges,e2;
vector<par>g[N];

int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n)if(pa[i-1][x]!=-1){
    pa[i][x]=pa[i-1][pa[i-1][x]];
    c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  rfor(i,K,0)if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  if(x==y)return res;
  rfor(i,K,0)if(pa[i][x]!=pa[i][y]){
    res=max({res,c[i][x],c[i][y]});
    x=pa[i][x],y=pa[i][y];
  }
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  auto cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
  }
  fore(i,0,n)ufPa[i]=i;
  t=kruskal();
  lca_init();
  // debug();
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    auto timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>1.6) {
      printf("DEMETRIO\n");
      return 0;
    }
  }
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,int>par;
#define fore(i,ii,iii) for(int i=ii;i<iii;i++)
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
#define fst first
#define snd second

const int K=18,N=1<<18;
int n,m,pa[K][N],sz[N],d[N],ufPa[N],ufSz[N];
ll c[K][N],t,r[N];

typedef pair<ll,pair<int,int>> edge;
vector<edge>edges,e2;
vector<par>g[N];
double cl,timer;
int find_parent(int x) {
  while(x!=ufPa[x])x=find_parent(ufPa[x]);
  return ufPa[x];
}
bool join(int x,int y) {
  x=find_parent(x),y=find_parent(y);
  if(x==y)return 0;
  if(sz[y]>sz[x])ufPa[x]=y,ufSz[y]+=ufSz[x];
  else ufPa[y]=x,ufSz[x]+=ufSz[y];
  return 1;
}
ll kruskal() {
  ll res=0;
  sort(edges.begin(),edges.end());
  for(auto it:edges) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("4 FANTASTICOS\n");
      exit(0);
    }
    int u=it.snd.fst,v=it.snd.snd;
    if(join(u,v)) {
      g[u].pb({it.fst,v});
      g[v].pb({it.fst,u});
      res+=it.fst;
    }
  }
  return res;
}
void lca_dfs(int v) {
  for(par p:g[v]) {
    if(p.snd!=pa[0][v]) {
      pa[0][p.snd]=v;
      c[0][p.snd]=p.fst;
      d[p.snd]=d[v]+1;
      lca_dfs(p.snd);
    }
  }
}
void lca_init() {
  mset(pa,-1);
  lca_dfs(0);
  fore(i,1,K)fore(x,0,n){
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 9\n");
      exit(0);
    }
    if(pa[i-1][x]!=-1){
      pa[i][x]=pa[i-1][pa[i-1][x]];
      c[i][x]=max(c[i-1][x],c[i-1][pa[i-1][x]]);
    }
  }
}
int query(int x,int y) {
  ll res=0;
  if(d[x]<d[y])swap(x,y);
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 7\n");
      exit(0);
    }
    assert(x>=0 && y>=0);
    if(d[x]-(1<<i)>=d[y])res=max(res,c[i][x]),x=pa[i][x];
  }
  if(x==y)return res;
  for(int i=K-1;i>=0;i--) {
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 8\n");
      exit(0);
    }
    if(pa[i][x]!=pa[i][y]){
      res=max({res,c[i][x],c[i][y]});
      assert(x>=0 && y>=0);
      x=pa[i][x],y=pa[i][y];
    }
  }
  assert(x>=0 && y>=0);
  res=max({res,c[0][x],c[0][y]});
  return res;
}

int main() {
  cl=clock();
  scanf("%d%d",&n,&m);
  fore(i,0,m) {
    int u,v;ll w;
    scanf("%d%d%lld",&u,&v,&w);u--,v--;
    edges.pb({w,{u,v}});
    e2.pb({w,{u,v}});
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.5) {
      printf("DEMETRIO 6\n");
      return 0;
    }
  }
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 1\n");
    return 0;
  }
  fore(i,0,n)ufPa[i]=i;
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.5) {
    printf("DEMETRIO 2\n");
    return 0;
  }
  t=kruskal();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 3\n");
    return 0;
  }
  lca_init();
  // debug();
  timer=((clock()-cl)*1./CLOCKS_PER_SEC);
  if(timer>0.1) {
    printf("DEMETRIO 4\n");
    return 0;
  }
  assert(e2.size()==m);
  for(auto it:e2){
    printf("%lld\n",t+it.fst-query(it.snd.fst,it.snd.snd));
    timer=((clock()-cl)*1./CLOCKS_PER_SEC);
    if(timer>0.1) {
      printf("DEMETRIO 5\n");
      return 0;
    }
  }
  return 0;
  // printf("%f\n",(clock()-cl)*1./CLOCKS_PER_SEC);
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]==x?x:fd(f[x]);}
inline void un(int x,int y,int z){
	x=fd(x);
	y=fd(y);
	int i,j;
	if(s[x].size()<s[y].size()) swap(s[x],s[y]);
	f[y]=x;
	while(s[y].size()){
		if(s[x].find(*s[y].begin())!=s[x].end()) ans[*s[y].begin()]-=z;
		else s[x].insert(*s[y].begin());
		s[y].erase(*s[y].begin());
	}
}
inline void Kruskal(int n){
	int i,j;
	for(i=1;i<=n;i++){
		int x,y,z;
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,m,i,j,x,y,z;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>x>>y>>z;
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	Kruskal(m);
	for(i=1;i<=m;i++) cout<<ans[i]+chushi<<endl;
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]=f[x]==x?x:fd(f[x]); }
inline void un(int x,int y,int z){
    x=fd(x),y=fd(y);
	if(s[x].size()<s[y].size()) {swap(s[x], s[y]);}
	f[y]=x;
	while(s[y].size()) {
		if(s[x].find(*s[y].begin()) != s[x].end()) {
			ans[*s[y].begin()]-=z;
		}
		else s[x].insert(*s[y].begin());
		s[y].erase(s[y].begin());
	}
}

int main(){
	int n,m,i,j,x,y,z;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	for(i=1;i<=m;i++){
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
	for(i=1;i<=m;i++) printf("%I64d\n",ans[i]+chushi);
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]=f[x]==x?x:fd(f[x]); }
inline void un(int x,int y,int z){
    x=fd(x);
	y=fd(y);
	if(s[x].size()<s[y].size()) {swap(s[x], s[y]);}
	f[y]=x;
	while(s[y].size()) {
		if(s[x].find(*s[y].begin()) != s[x].end()) {
			ans[*s[y].begin()]-=z;
		}
		else s[x].insert(*s[y].begin());
		s[y].erase(s[y].begin());
	}
}

int main(){
	int n,m,i,j,x,y,z;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	for(i=1;i<=m;i++){
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
	for(i=1;i<=m;i++) printf("%I64d\n",ans[i]+chushi);
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]==x?x:fd(f[x]);}
inline void un(int x,int y,int z){
	x=fd(x);
	y=fd(y);
	int i,j;
	if(s[x].size()<s[y].size()) swap(s[x],s[y]);
	f[y]=x;
	while(s[y].size()){
		if(s[x].find(*s[y].begin())!=s[x].end()) ans[*s[y].begin()]-=z;
		else s[x].insert(*s[y].begin());
		s[y].erase(*s[y].begin());
	}
}
inline void Kruskal(int n){
	int i,j;
	for(i=1;i<=n;i++){
		int x,y,z;
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,m,i,j,x,y,z;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	Kruskal(m);
	for(i=1;i<=m;i++) printf("%I64d\n",ans[i]+chushi);
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]==x?x:fd(f[x]);}
inline void un(int x,int y,int z){
	x=fd(x);
	y=fd(y);
	int i,j;
	if(s[x].size()<s[y].size()) swap(s[x],s[y]);
	f[y]=x;
	while(s[y].size()){
		if(s[x].find(*s[y].begin())!=s[x].end()) ans[*s[y].begin()]-=z;
		else s[x].insert(*s[y].begin());
		s[y].erase(*s[y].begin());
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,m,i,j,x,y,z;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	for(i=1;i<=m;i++){
		int x,y,z;
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
	for(i=1;i<=m;i++) printf("%I64d\n",ans[i]+chushi);
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn],chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]==x?x:fd(f[x]);}
inline void un(int x,int y,int z){
	x=fd(x);
	y=fd(y);
	int i,j;
	if(s[x].size()<s[y].size()) swap(s[x],s[y]);
	f[y]=x;
	while(s[y].size()){
		if(s[x].find(*s[y].begin())!=s[x].end()) ans[*s[y].begin()]-=z;
		else s[x].insert(*s[y].begin());
		s[y].erase(*s[y].begin());
	}
}
inline void Kruskal(int n){
	int i,j;
	for(i=1;i<=n;i++){
		int x,y,z;
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	int n,m,i,j,x,y,z;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>x>>y>>z;
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	Kruskal(m);
	for(i=1;i<=m;i++) cout<<ans[i]+chushi<<endl;
	return 0;
}


#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
const int Mxn=200005;
int f[Mxn];
long long chushi,ans[Mxn];
set<int> s[Mxn];
iii E[Mxn];
inline int fd(int x){return f[x]==x?x:fd(f[x]);}
inline void un(int x,int y,int z){
	x=fd(x);
	y=fd(y);
	int i,j;
	if(s[x].size()<s[y].size()) swap(s[x],s[y]);
	f[y]=x;
	while(s[y].size()){
		if(s[x].find(*s[y].begin())!=s[x].end()) ans[*s[y].begin()]-=z;
		else s[x].insert(*s[y].begin());
		s[y].erase(*s[y].begin());
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int n,m,i,j,x,y,z;
	scanf("%d %d",&n,&m);
	for(i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		s[x].insert(i);
		s[y].insert(i);
		E[i]=mp(z,mp(x,y));
		ans[i]=z;
	}
	for(i=1;i<=n;i++) f[i]=i;
	sort(E+1,E+m+1);
	chushi=0;
	for(i=1;i<=m;i++){
		x=E[i].second.first,y=E[i].second.second,z=E[i].first;
		if(fd(x)==fd(y)) continue;
		un(x,y,z);
		chushi+=z;
	}
	for(i=1;i<=m;i++) printf("%I64d\n",ans[i]+chushi);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,ll> > g[maxn],Tree[maxn];
vector<pair<ll,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,ll cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[par[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(n1==n2)
            break;
        if(par[n1][i]==par[n2][i] and i)
            continue;
        n1=par[n1][i];
        n2=par[n2][i];
    }
    return n1;
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2;
        ll cost;
        si(n1); si(n2); sll(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,ll> > g[maxn],Tree[maxn];
vector<pair<ll,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,ll cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[par[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff and par[n1][i]!=-1){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(par[n1][i]!=par[n2][i]){
            n1=par[n1][i];
            n2=par[n2][i];
        }
    }
    if(n1==n2)
        return n1;
    return par[n1][0];
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2;
        ll cost;
        si(n1); si(n2); sll(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j)<=diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j)<=diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,int> > g[maxn],Tree[maxn];
vector<pair<int,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,int cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[weight[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(n1==n2)
            break;
        if(par[n1][i]==par[n2][i] and i)
            continue;
        n1=par[n1][i];
        n2=par[n2][i];
    }
    return n1;
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2,cost;
        si(n1); si(n2); si(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=1e6+5;
vector<pair<int,int> > g[maxn],Tree[maxn];
vector<pair<int,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,int cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[weight[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(n1==n2)
            break;
        if(par[n1][i]==par[n2][i] and i)
            continue;
        n1=par[n1][i];
        n2=par[n2][i];
    }
    return n1;
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2,cost;
        si(n1); si(n2); si(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,ll> > g[maxn],Tree[maxn];
vector<pair<ll,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,ll cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[par[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(par[n1][i]!=par[n2][i]){
            n1=par[n1][i];
            n2=par[n2][i];
        }
    }
    if(n1==n2)
        return n1;
    return par[n1][0];
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2;
        ll cost;
        si(n1); si(n2); sll(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,int> > g[maxn],Tree[maxn];
vector<pair<int,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,ll cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[par[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(n1==n2)
            break;
        if(par[n1][i]==par[n2][i] and i)
            continue;
        n1=par[n1][i];
        n2=par[n2][i];
    }
    return n1;
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2,cost;
        si(n1); si(n2); si(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j) & diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include <bits/stdc++.h>
using namespace std;
#define si(x)       scanf("%d",&x)
#define sll(x)       scanf("%lld",&x)
#define sf(x)       scanf("%f",&x)
#define slf(x)      scanf("%Lf",&x)
#define pri(x)      printf("%d\n",x)
#define prl(x)      printf("%lld\n",x)
#define ll          long long int
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define pll         pair<long long,long long>
#define pil         pair<int,long long>
#define pli         pair<long long,int>
#define vi          vector<int>
#define vl          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define M           1000000007

const int maxn=2e5+5;
vector<pair<int,ll> > g[maxn],Tree[maxn];
vector<pair<ll,pair<int,int> > >edges;
int par[maxn][32],n,m;
ll weight[maxn][32];
int rnk[maxn],Par[maxn];
int depth[maxn];
ll ans[maxn];
map<pair<int,int>,int>tree,id;

void dfs(int node,int parent,ll cost,int deep){
    par[node][0]=parent;
    weight[node][0]=cost;
    depth[node]=deep;

    rep(i,0,sz(Tree[node])-1){
        if(Tree[node][i].F==parent)
            continue;
        dfs(Tree[node][i].F,node,Tree[node][i].S,deep+1);
    }
}

void init(){
    dfs(1,-1,0,0);
    rep(i,1,n){
        rep(j,1,31){
            par[i][j]=-1;
        }
    }
    rep(j,1,31){
        rep(i,1,n){
            if(par[i][j-1]!=-1){
                par[i][j]=par[par[i][j-1]][j-1];
                weight[i][j]=max(weight[i][j-1],weight[par[i][j-1]][j-1]);
            }
        }
    }
}

int LCA(int n1,int n2){
    if(depth[n1]<depth[n2]){
        swap(n1,n2);
    }
    int diff=depth[n1]-depth[n2];

    rep(i,0,30){
        if((1<<i)&diff){
            n1=par[n1][i];
        }
    }

    rrep(i,30,0){
        if(n1==n2)
            break;
        if(par[n1][i]==par[n2][i] and i)
            continue;
        n1=par[n1][i];
        n2=par[n2][i];
    }
    return n1;
}

int fnd(int node){
    if(node!=Par[node]){
        Par[node]=fnd(Par[node]);
    }
    return Par[node];
}

void unn(int node1,int node2){
    int p1=fnd(node1);
    int p2=fnd(node2);
    if(p1==p2)
        return;
    if(rnk[p1]>rnk[p2]){
        Par[p2]=p1;
    }
    else if(rnk[p2]>rnk[p1]){
        Par[p1]=p2;
    }
    else{
        Par[p1]=p2;
        rnk[p2]++;
    }

}

void solve(){

    si(n);  si(m);

    rep(i,1,m){
        int n1,n2;
        ll cost;
        si(n1); si(n2); sll(cost);
        g[n1].pb({n2,cost});
        g[n2].pb({n1,cost});
        edges.pb({cost,{n1,n2}});
        id[{n1,n2}]=i;
        id[{n2,n1}]=i;
    }

    rep(i,1,n){
        rnk[i]=1;
        Par[i]=i;
    }

    sort(all(edges));

    ll cost=0;
    int ind=0;
    int cnt=0;

    while(cnt!=n-1){
        int n1=edges[ind].S.F;
        int n2=edges[ind].S.S;
        if(fnd(n1)==fnd(n2)){
            ind++;
            continue;
        }
        unn(n1,n2);
        cost+=edges[ind].F;
        tree[{n1,n2}]=1;
        Tree[n1].pb({n2,edges[ind].F});
        Tree[n2].pb({n1,edges[ind].F});
        tree[{n2,n1}]=1;
        ind++;
        cnt++;
    }

    init();

    rep(i,0,m-1){
        int n1=edges[i].S.F;
        int n2=edges[i].S.S;
        if(tree[{n1,n2}]){
            ans[id[{n1,n2}]]=cost;
        }
        else{
            ans[id[{n1,n2}]]=cost+edges[i].F;
            int lca=LCA(n1,n2);
            int diff=depth[n1]-depth[lca];
            ll cost1=0;
            int n11=n1;
            rrep(j,30,0){
                if((1<<j)<=diff){
                    cost1=max(cost1,weight[n11][j]);
                    diff-=(1<<j);
                    n11=par[n11][j];
                }
            }
            diff=depth[n2]-depth[lca];
            int n22=n2;
            rrep(j,30,0){
                if((1<<j)<=diff){
                    cost1=max(cost1,weight[n22][j]);
                    diff-=(1<<j);
                    n22=par[n22][j];
                }
            }
            ans[id[{n1,n2}]]-=cost1;
        }
    }
    rep(i,1,m){
        cout<<ans[i]<<endl;
    }

}

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1;
    //si(t);
    while(t--){
        solve();
    }

}


#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=0;i<l;i++)
        {
            if(x&1){
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
            x>>=1;
        }
    }
    if(u == v)
        return ans;
    for(int i=0;i<l;i++)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    if(m == 0)
    {
        cout<<"0\n";
        return 0;
    }
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=l-1;i>=0;i--)
        {
            if(x&(1<<i))
            {
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
        }
    }
    if(u == v)
        return ans;
    for(int i=l-1;i>=0;i--)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    if(m == 0)
    {
        return 0;
    }
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    return 0;
}