#include <bits/stdc++.h>
const int maxn = 200200;
int n, m;
struct T {
  int to, nxt, v;
} way[maxn << 1];
int h[maxn], num;
inline void adde(int x, int y, int v) {
  way[++num] = {y, h[x], v}, h[x] = num;
  way[++num] = {x, h[y], v}, h[y] = num;
}
int bz[maxn][20], mx[maxn][20];
int vis[maxn], dep[maxn];
inline void dfs(int x) {
  vis[x] = 1, dep[x] = dep[*bz[x]] + 1;
  for (int i = 1; i < 20; ++i)
    bz[x][i] = bz[bz[x][i - 1]][i - 1],
    mx[x][i] = std::max(mx[x][i - 1], mx[bz[x][i - 1]][i - 1]);
  for (int i = h[x]; i; i = way[i].nxt)
    if (!vis[way[i].to])
      *mx[way[i].to] = way[i].v, *bz[way[i].to] = x, dfs(way[i].to);
}
inline void up(int& x, int y) {
  if (x < y) x = y;
}
inline int get(int x, int y) {
  int ans = 0;
  if (dep[x] > dep[y]) std::swap(x, y);
  for (int t = dep[y] - dep[x]; t; t &= t - 1)
    up(ans, mx[y][__builtin_ctz(t)]), y = bz[y][__builtin_ctz(t)];
  if (x == y) return ans;
  for (int i = 19; ~i; --i)
    if (bz[x][i] != bz[y][i])
      up(ans, std::max(mx[x][i], mx[y][i])), x = bz[x][i], y = bz[y][i];
  return std::max(ans, std::max(*mx[x], *mx[y]));
}
int x[maxn], y[maxn], v[maxn];
int rk[maxn], fa[maxn];
inline int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  std::cin >> n >> m;
  for (int i = 1; i <= m; ++i) std::cin >> x[i] >> y[i] >> v[i], rk[i] = i;
  for (int i = 1; i <= n; ++i) fa[i] = i;
  std::sort(rk + 1, rk + m + 1, [](int x, int y) { return v[x] < v[y]; });
  long long sum = 0;
  for (int i = 1; i <= m; ++i) {
    int t = rk[i];
    if (find(x[t]) != find(y[t])) {
      fa[find(x[t])] = find(y[t]);
      adde(x[t], y[t], v[t]);
      sum += v[t];
    }
  }
  dfs(1);
  for (int i = 1; i <= m; ++i)
    std::cout << sum + v[i] - get(x[i], y[i]) << '\n';
}
