#include <bits/stdc++.h>
using namespace std;
long long head[200005 * 2], lg[200005 * 4];
struct acb {
  long long next, to, w;
} tree[200005 * 2];
long long cut;
void Add(long long u, long long v, long long w) {
  tree[++cut].to = v;
  tree[cut].next = head[u];
  tree[cut].w = w;
  head[u] = cut;
}
long long anc[200005][30], dept[200005], walth[200005][30];
long long n, m, fa[200005], top, len;
bool bin[200005];
struct abc {
  long long u, v, w, ty, id;
} edge[200005 * 2];
bool cmp(abc x, abc y) { return x.w < y.w; }
bool rbq(abc x, abc y) { return x.id < y.id; }
long long Find(long long x) {
  while (x != fa[x]) x = fa[x] = fa[fa[x]];
  return x;
}
void add(long long u, long long v, long long w) {
  edge[++top].v = v;
  edge[top].w = w;
  edge[top].u = u;
  edge[top].ty = top;
}
long long kruskal() {
  sort(edge + 1, edge + m + 1, cmp);
  long long cnt = 0, res = 0;
  for (long long i = 1; i <= m; i++) {
    long long u = edge[i].u, v = edge[i].v;
    long long rootx = Find(u), rooty = Find(v);
    if (rootx == rooty) continue;
    bin[edge[i].ty] = true;
    Add(u, v, edge[i].w);
    Add(v, u, edge[i].w);
    res += edge[i].w;
    fa[rooty] = rootx;
    if (++cnt == n - 1) break;
  }
  return res;
}
void dfs(long long u, long long fath, long long w) {
  dept[u] = dept[fath] + 1;
  anc[u][0] = fath;
  walth[u][0] = w;
  for (int i = 1; (1 << i) <= dept[u]; i++) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
    walth[u][i] = max(walth[u][i - 1], walth[anc[u][i - 1]][i - 1]);
  }
  for (int i = head[u]; i; i = tree[i].next) {
    if (fath != tree[i].to) {
      dfs(tree[i].to, u, tree[i].w);
    }
  }
}
long long LCA(long long x, long long y) {
  if (dept[x] < dept[y]) swap(x, y);
  long long maxx = -1, maxy = -1;
  while (dept[x] > dept[y]) {
    maxx = max(maxx, walth[x][lg[dept[x] - dept[y]] - 1]);
    x = anc[x][lg[dept[x] - dept[y]] - 1];
  }
  if (x == y) return maxx;
  for (int i = lg[dept[x]] - 1; i >= 0; i--) {
    if (anc[x][i] != anc[y][i]) {
      maxx = max(maxx, walth[x][i]);
      maxy = max(maxy, walth[y][i]);
      x = anc[x][i];
      y = anc[y][i];
    }
  }
  maxx = max(walth[x][0], maxx);
  maxy = max(walth[y][0], maxy);
  return max(maxx, maxy);
}
bool check(long long x) {
  if (bin[x])
    return true;
  else
    return false;
}
long long work(long long x) {
  long long res = len;
  if (check(x))
    return res;
  else
    res += edge[x].w;
  long long u = edge[x].u;
  long long v = edge[x].v;
  long long lens = LCA(u, v);
  return res - lens;
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) fa[i] = i;
  for (long long i = 1; i <= m; i++) {
    long long u, v, w;
    edge[i].id = i;
    scanf("%lld%lld%lld", &u, &v, &w);
    add(u, v, w);
  }
  len = kruskal();
  sort(edge + 1, edge + m + 1, rbq);
  lg[1] = 1;
  for (int i = 2; i <= 200005; i++) lg[i] = lg[i - 1] + ((1 << lg[i - 1]) == i);
  dfs(1, 0, 0);
  for (long long i = 1; i <= m; i++) {
    long long ans = work(i);
    printf("%lld\n", ans);
  }
  return 0;
}
