#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, pair<long long, long long> > > gp, gp1;
vector<pair<long long, long long> > mst[212345];
long long fd[212345];
long long vx, e;
long long find(long long x) {
  if (x == fd[x]) return x;
  return fd[x] = find(fd[x]);
}
long long makeMst() {
  long long ans = 0;
  for (long long i = 0; i < 212345; i++) fd[i] = i;
  long long nv = 0;
  for (long long i = 0; i < gp.size(); i++) {
    if (nv == vx - 1) break;
    long long x = gp[i].second.first, y = gp[i].second.second, w = gp[i].first;
    long long u = find(x), v = find(y);
    if (u == v) continue;
    mst[x].push_back(make_pair(w, y));
    mst[y].push_back(make_pair(w, x));
    ans += w;
    fd[u] = v;
    nv++;
  }
  return ans;
}
long long pa[212345][19], wt[212345][19], lv[212345];
void dfs(long long node, long long pat, long long w, long long lvl) {
  if (pa[node][0] != node) return;
  pa[node][0] = pat;
  wt[node][0] = w;
  lv[node] = lvl;
  for (long long i = 0; i < mst[node].size(); i++) {
    long long xx = mst[node][i].second;
    if (pa[xx][0] == xx) dfs(xx, node, mst[node][i].first, lvl + 1);
  }
}
void calParent() {
  for (long long i = 1; i < 19; i++) {
    for (long long j = 1; j <= vx; j++) {
      if (pa[j][i - 1] != -1)
        pa[j][i] = pa[pa[j][i - 1]][i - 1];
      else
        pa[j][i] = -1;
      wt[j][i] = max(wt[pa[j][i - 1]][i - 1], wt[j][i - 1]);
    }
  }
}
long long qlca(long long u, long long v) {
  if (lv[u] > lv[v]) swap(u, v);
  long long diff = lv[v] - lv[u];
  long long ct = 0;
  while (diff) {
    if (diff % 2 == 1) v = pa[v][ct];
    ct++;
    diff = diff / 2;
  }
  if (u == v) return u;
  for (long long i = 19 - 1; i >= 0; i--) {
    if (pa[u][i] != pa[v][i]) {
      u = pa[u][i];
      v = pa[v][i];
    }
  }
  return pa[u][0];
}
long long qwt(long long u, long long v) {
  if (lv[u] > lv[v]) swap(u, v);
  long long diff = lv[v] - lv[u];
  long long ct = 0;
  long long ans = 0;
  while (diff) {
    if (diff % 2 == 1) {
      ans = max(ans, wt[v][ct]);
      v = pa[v][ct];
    }
    ct++;
    diff = diff / 2;
  }
  return ans;
}
int main() {
  scanf("%lld%lld", &vx, &e);
  for (long long i = 0; i < e; i++) {
    long long x, y, w;
    scanf("%lld%lld%lld", &x, &y, &w);
    gp.push_back(make_pair(w, make_pair(x, y)));
    gp1.push_back(make_pair(w, make_pair(x, y)));
  }
  sort(gp.begin(), gp.end());
  long long wmst = makeMst();
  for (long long i = 0; i <= vx; i++) pa[i][0] = i;
  dfs(1, -1, 0, 1);
  calParent();
  for (long long i = 0; i < e; i++) {
    long long u = gp1[i].second.first, v = gp1[i].second.second,
              w = gp1[i].first;
    long long lca = qlca(u, v);
    long long ans = max(qwt(u, lca), qwt(v, lca));
    cout << wmst - ans + w << endl;
  }
}
