#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int n, m, cnt;
long long ans;
struct Edge {
  int x, y, c, id, u;
  inline friend bool operator<(const Edge &a, const Edge &b) {
    return a.c < b.c;
  }
} E[200010];
inline bool cmp(Edge a, Edge b) { return a.id < b.id; }
int g[200010], dep[200010];
int f[200010];
int fa[200010][20], fas[200010][20];
struct edge {
  int t, c, next;
} e[400010];
inline void add_edge(int x, int y, int z) {
  e[++cnt].t = y;
  e[cnt].c = z;
  e[cnt].next = g[x];
  g[x] = cnt;
}
inline int Find(int x) { return f[x] = x == f[x] ? x : Find(f[x]); }
inline void dfs(int x) {
  for (int i = 1; i < 20; i++) {
    fa[x][i] = fa[fa[x][i - 1]][i - 1];
    fas[x][i] = max(fas[fa[x][i - 1]][i - 1], fas[x][i - 1]);
  }
  for (int i = g[x]; i; i = e[i].next)
    if (!dep[e[i].t]) {
      dep[e[i].t] = dep[x] + 1;
      fa[e[i].t][0] = x;
      fas[e[i].t][0] = e[i].c;
      dfs(e[i].t);
    }
}
inline void swim(int &x, int h) {
  for (int i = 0; h; i++) {
    if (h & 1) x = fa[x][i];
    h >>= 1;
  }
}
inline int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  swim(x, dep[x] - dep[y]);
  for (int i = 19; x != y; i--)
    if (fa[x][i] != fa[y][i] || i == 0) {
      x = fa[x][i];
      y = fa[y][i];
      if (i == 0) i++;
    }
  return x;
}
inline int lnma(int x, int y) {
  int h = dep[x] - dep[y], temp = 0;
  for (int i = 0; h; i++) {
    if (h & 1) {
      temp = max(temp, fas[x][i]);
      x = fa[x][i];
    }
    h >>= 1;
  }
  return temp;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &E[i].x, &E[i].y, &E[i].c);
    E[i].id = i;
  }
  sort(E + 1, E + m + 1);
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1; i <= m; i++) {
    if (Find(E[i].x) != Find(E[i].y)) {
      E[i].u = 1;
      f[Find(E[i].x)] = Find(E[i].y);
      ans += (long long)E[i].c;
      add_edge(E[i].x, E[i].y, E[i].c);
      add_edge(E[i].y, E[i].x, E[i].c);
    }
  }
  fas[1][0] = INF;
  fa[1][0] = 1;
  dep[1] = 1;
  dfs(1);
  sort(E + 1, E + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    int x = E[i].x, y = E[i].y;
    int z = LCA(x, y);
    if (E[i].u)
      printf("%I64d\n", ans);
    else {
      int temp = max(lnma(x, z), lnma(y, z));
      printf("%I64d\n", ans - temp + E[i].c);
    }
  }
  return 0;
}
