#include <bits/stdc++.h>
using namespace std;
struct A {
  int u, v, w, i;
  bool operator<(const A& o) const { return w < o.w; }
};
A E[250100];
int p[250100];
int level[250100];
int dp[18][250100];
long long MAX[18][250100];
int mark[250100];
long long ans[250100];
long long sum;
vector<pair<int, int> > g[250100];
int fin(int i) { return p[i] == i ? i : p[i] = fin(p[i]); }
void dfs(int now, int state = 1, int p = 0) {
  level[now] = state;
  for (auto x : g[now]) {
    if (x.first == p) continue;
    dfs(x.first, state + 1, now);
    dp[0][x.first] = now;
    MAX[0][x.first] = x.second;
  }
}
long long LCA(int u, int v) {
  long long ma = 0;
  if (level[u] < level[v]) swap(u, v);
  for (int i = 17; i >= 0; i--)
    if (level[dp[i][u]] >= level[v]) ma = max(ma, MAX[i][u]), u = dp[i][u];
  if (u == v) return ma;
  for (int i = 17; i >= 0; i--)
    if (dp[i][u] != dp[i][v])
      ma = max(ma, max(MAX[i][u], MAX[i][v])), u = dp[i][u], v = dp[i][v];
  return max(ma, max(MAX[0][u], MAX[0][v]));
}
int main() {
  int n, m, u, v, w;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &u, &v, &w);
    E[i] = {u, v, w, i};
  }
  sort(E, E + m);
  for (int i = 0; i < m; i++) {
    int pu = fin(E[i].u), pv = fin(E[i].v);
    if (pu != pv) {
      mark[i] = 1;
      p[pu] = pv;
      sum += E[i].w;
      g[E[i].u].push_back({E[i].v, E[i].w});
      g[E[i].v].push_back({E[i].u, E[i].w});
    }
  }
  dfs(1);
  for (int i = 1; i <= 17; i++)
    for (int j = 1; j <= n; j++)
      dp[i][j] = dp[i - 1][dp[i - 1][j]],
      MAX[i][j] = max(MAX[i - 1][j], MAX[i - 1][dp[i - 1][j]]);
  for (int i = 0; i < m; i++) {
    int u = E[i].u, v = E[i].v;
    if (mark[i])
      ans[E[i].i] = sum;
    else
      ans[E[i].i] = sum + E[i].w - LCA(u, v);
  }
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
  return 0;
}
