#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000007;
const int maxn = 2e5 + 7;
const double eps = 1e-12;
const long long mod = 998244353;
int n = 0, m, k, cnt;
int vis[maxn], fa[maxn];
long long ans;
bool use[maxn];
int f[maxn][20], g[maxn][20], deep[maxn], head[maxn];
struct Edge {
  int u, v, w, id;
} mp[maxn];
struct edge {
  int next, to, val;
} e[maxn * 2];
int cmp(const Edge a, const Edge b) { return a.w < b.w; }
int cmp1(const Edge a, const Edge b) { return a.id < b.id; }
void addedge(int u, int v, int w) {
  e[++cnt].next = head[u];
  e[cnt].to = v;
  e[cnt].val = w;
  head[u] = cnt;
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
void Kruskal() {
  sort(mp + 1, mp + 1 + m, cmp);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    int f1 = find(mp[i].u), f2 = find(mp[i].v);
    if (f1 == f2) continue;
    fa[f1] = f2;
    use[mp[i].id] = true;
    ans += mp[i].w;
    addedge(mp[i].u, mp[i].v, mp[i].w);
    addedge(mp[i].v, mp[i].u, mp[i].w);
  }
}
void dfs(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (vis[v]) continue;
    f[v][0] = x;
    deep[v] = deep[x] + 1;
    g[v][0] = e[i].val;
    dfs(v);
  }
}
int maxx;
void go(int &x, int d) {
  for (int i = 0; i < 20; i++) {
    if (d & (1 << i)) {
      maxx = max(g[x][i], maxx);
      x = f[x][i];
    }
  }
}
void lca(int x, int y) {
  if (deep[x] > deep[y])
    go(x, deep[x] - deep[y]);
  else
    go(y, deep[y] - deep[x]);
  if (x == y) return;
  for (int i = 19; i >= 0; i--) {
    if (f[x][i] != f[y][i]) {
      maxx = max(maxx, max(g[x][i], g[y][i]));
      x = f[x][i];
      y = f[y][i];
    }
  }
  maxx = max(maxx, max(g[x][0], g[y][0]));
  return;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = 1; i <= m; i++) {
      scanf("%d%d%d", &mp[i].u, &mp[i].v, &mp[i].w);
      mp[i].id = i;
    }
    Kruskal();
    deep[1] = 1;
    dfs(1);
    for (int j = 1; j < 20; j++) {
      for (int i = 1; i <= n; i++) {
        f[i][j] = f[f[i][j - 1]][j - 1];
        g[i][j] = max(g[i][j - 1], g[f[i][j - 1]][j - 1]);
      }
    }
    sort(mp + 1, mp + 1 + m, cmp1);
    for (int i = 1; i <= m; i++) {
      if (use[i])
        printf("%lld\n", ans);
      else {
        maxx = 0;
        lca(mp[i].u, mp[i].v);
        printf("%lld\n", (long long)ans - maxx + mp[i].w);
      }
    }
  }
}
