#include <bits/stdc++.h>
using namespace std;
int n, m, head[200001], cnt1, fa[200001], dep[200001], siz[200001], son[200001],
    top[200001], id[200001], cnt2, a[200001], b[200001], s[200001 << 2];
long long ans;
struct Edge {
  int a, b, c;
} e1[200001], e2[200001], e[200001 << 1];
inline void add(int a, int b, int c) {
  e[++cnt1].a = head[a], e[cnt1].b = b, e[cnt1].c = c, head[a] = cnt1;
}
inline bool cmp(const Edge &a, const Edge &b) { return a.c < b.c; }
inline int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
inline void dfs1(int x, int y) {
  fa[x] = y;
  dep[x] = dep[y] + 1;
  siz[x] = 1;
  for (register int i = head[x]; i; i = e[i].a) {
    if (e[i].b == y) continue;
    a[e[i].b] = e[i].c;
    dfs1(e[i].b, x);
    siz[x] += siz[e[i].b];
    if (siz[e[i].b] > siz[son[x]]) son[x] = e[i].b;
  }
}
inline void dfs2(int x, int y) {
  top[x] = y;
  id[x] = ++cnt2;
  b[cnt2] = a[x];
  if (!son[x]) return;
  dfs2(son[x], y);
  for (register int i = head[x]; i; i = e[i].a) {
    if (e[i].b == fa[x] || e[i].b == son[x]) continue;
    dfs2(e[i].b, e[i].b);
  }
}
inline void build(int p, int l, int r) {
  if (l == r) {
    s[p] = b[l];
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  s[p] = max(s[p << 1], s[p << 1 | 1]);
}
inline int query(int p, int l, int r, int x, int y) {
  if (x <= l && r <= y) return s[p];
  int mid = (l + r) >> 1, ans = 0;
  if (mid >= x) ans = query(p << 1, l, mid, x, y);
  if (mid < y) ans = max(ans, query(p << 1 | 1, mid + 1, r, x, y));
  return ans;
}
inline int query(int x, int y) {
  int ans = 0;
  while (top[x] != top[y]) {
    if (dep[top[x]] < dep[top[y]]) swap(x, y);
    ans = max(ans, query(1, 1, n, id[top[x]], id[x]));
    x = fa[top[x]];
  }
  if (dep[x] > dep[y]) swap(x, y);
  if (x != y) ans = max(ans, query(1, 1, n, id[x] + 1, id[y]));
  return ans;
}
signed main() {
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; i++)
    scanf("%d%d%d", &e1[i].a, &e1[i].b, &e1[i].c), e2[i] = e1[i];
  for (register int i = 1; i <= n; i++) fa[i] = i;
  sort(e2 + 1, e2 + m + 1, cmp);
  for (register int i = 1; i <= m; i++)
    if (find(e2[i].a) != find(e2[i].b))
      add(e2[i].a, e2[i].b, e2[i].c), add(e2[i].b, e2[i].a, e2[i].c),
          ans += e2[i].c, fa[find(e2[i].a)] = find(e2[i].b);
  dfs1(1, 0), dfs2(1, 1);
  build(1, 1, n);
  for (register int i = 1; i <= m; i++) {
    if (fa[e1[i].a] == e1[i].b || fa[e1[i].b] == e1[i].a) {
      printf("%lld\n", ans);
      continue;
    }
    printf("%lld\n", ans + e1[i].c - query(e1[i].a, e1[i].b));
  }
  return 0;
}
