#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<long long, pair<long long, pair<long long, long long> > > >
    q;
priority_queue<pair<long long, pair<long long, pair<long long, long long> > > >
    q2;
long long ver[200001 * 2], nxt[200001 * 2], edge[200001 * 2], he[200001],
    d[200001], tot, sum;
long long anc[200001][20], g[200001][20];
long long f[200001];
map<int, int> mp;
void add(long long x, long long y, long long z) {
  ver[++tot] = y;
  edge[tot] = z;
  nxt[tot] = he[x];
  he[x] = tot;
}
long long get(long long x) {
  if (x == f[x]) return x;
  return f[x] = get(f[x]);
}
void dfs(long long x, long long fa) {
  d[x] = d[fa] + 1;
  for (register int i = 1; i <= 18; i++) {
    anc[x][i] = anc[anc[x][i - 1]][i - 1];
    g[x][i] = max(g[x][i - 1], g[anc[x][i - 1]][i - 1]);
  }
  for (register int i = he[x]; i; i = nxt[i]) {
    if (ver[i] == fa) continue;
    anc[ver[i]][0] = x;
    g[ver[i]][0] = edge[i];
    dfs(ver[i], x);
  }
  return;
}
long long getlca(long long a, long long b) {
  if (d[a] < d[b]) swap(a, b);
  long long ans = -2147483647000000;
  for (register int i = 18; i >= 0; i--) {
    if (d[anc[a][i]] >= d[b]) ans = max(ans, g[a][i]), a = anc[a][i];
  }
  if (a == b) return ans;
  for (register int i = 18; i >= 0; i--) {
    if (anc[a][i] != anc[b][i])
      ans = max(ans, max(g[a][i], g[b][i])), a = anc[a][i], b = anc[b][i];
  }
  return max(ans, max(g[a][0], g[b][0]));
}
inline void read(long long &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
}
int main() {
  long long n, m;
  long long x, y, z;
  read(n);
  read(m);
  for (register int i = 1; i <= m; i++) {
    read(x);
    read(y);
    read(z);
    q.push(make_pair(-z, make_pair(i, make_pair(x, y))));
  }
  for (register int i = 1; i <= n; i++) f[i] = i;
  for (register int i = 1; i <= m; i++) {
    long long x = q.top().second.second.first, y = q.top().second.second.second,
              z = -q.top().first, id = q.top().second.first;
    q2.push(make_pair(-id, make_pair(z, make_pair(x, y))));
    q.pop();
    if (get(x) == get(y)) {
      continue;
    }
    sum += z;
    f[f[x]] = f[y];
    add(x, y, z);
    add(y, x, z);
    mp[id] = 1;
  }
  dfs(1, 0);
  while (!q2.empty()) {
    long long x = q2.top().second.second.first,
              y = q2.top().second.second.second, z = q2.top().second.first,
              id = -q2.top().first;
    if (mp[id] == 1) {
      printf("%lld\n", sum);
      q2.pop();
      continue;
    }
    q2.pop();
    long long rt = getlca(x, y);
    printf("%lld\n", sum - rt + z);
  }
}
