#include <bits/stdc++.h>
using namespace std;
int n, m;
long long ans[400000], sum, total;
bool mk[400000];
int f[400000], deep[400000], dp[400000][30], lg[400000], len[400000][30];
vector<int> to[400000], cst[400000];
struct A {
  int s, e, w, id;
} way[400000];
int getf(int x) {
  if (f[x] == x)
    return x;
  else
    f[x] = getf(f[x]);
  return f[x];
}
bool cmp(A x, A y) { return x.w < y.w; }
void dfs(int x) {
  deep[x] = deep[dp[x][0]] + 1;
  for (int i = 1; i <= lg[deep[x]] + 1; i++) {
    dp[x][i] = dp[dp[x][i - 1]][i - 1];
    len[x][i] = max(len[x][i - 1], len[dp[x][i - 1]][i - 1]);
  }
  for (int i = 0; i < to[x].size(); i++) {
    if (to[x][i] == dp[x][0]) continue;
    dp[to[x][i]][0] = x;
    len[to[x][i]][0] = cst[x][i];
    dfs(to[x][i]);
  }
  return;
}
int lca(int x, int y) {
  int flag = 0;
  if (deep[x] < deep[y]) swap(x, y);
  while (deep[x] > deep[y]) {
    flag = max(flag, len[x][lg[deep[x] - deep[y]]]);
    x = dp[x][lg[deep[x] - deep[y]]];
  }
  if (x == y) return flag;
  for (int i = lg[deep[x]]; i >= 0; i--)
    if (dp[x][i] != dp[y][i]) {
      flag = max(flag, len[x][i]);
      flag = max(flag, len[y][i]);
      x = dp[x][i];
      y = dp[y][i];
    }
  flag = max(flag, len[x][0]);
  flag = max(flag, len[y][0]);
  return flag;
}
int main() {
  int fa, fb;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    cin >> way[i].s >> way[i].e >> way[i].w;
    way[i].id = i;
  }
  sort(1 + way, 1 + m + way, cmp);
  for (int i = 1; i <= m; i++) {
    fa = getf(way[i].s);
    fb = getf(way[i].e);
    if (fa != fb) {
      f[fb] = fa;
      to[way[i].s].push_back(way[i].e);
      cst[way[i].s].push_back(way[i].w);
      to[way[i].e].push_back(way[i].s);
      cst[way[i].e].push_back(way[i].w);
      mk[i] = true;
      total += way[i].w;
      sum++;
      if (sum == n - 1) break;
    }
  }
  for (int i = 1, k = 2, l = 0; i <= n; i++) {
    if (i == k) k *= 2, l++;
    lg[i] = l;
  }
  dp[1][0] = 1;
  len[1][0] = 0;
  dfs(1);
  for (int i = 1; i <= m; i++) {
    if (mk[i])
      ans[way[i].id] = total;
    else {
      int k = lca(way[i].s, way[i].e);
      ans[way[i].id] = total + way[i].w - k;
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
  return 0;
}
