#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
struct eg {
  int u, v, nex, val, id;
  eg() {}
  eg(int _u, int _v, int _val, int _nex) {
    u = _u, v = _v, val = _val, nex = _nex;
  }
  bool operator<(eg a) const { return val < a.val; }
} edg[N << 2], MST[N];
long long int ans[N] = {0};
int sav[N][3], scnt;
int fir[N], ecnt, root;
int n, m;
void add(int u, int v, int val) {
  edg[ecnt] = eg(u, v, val, fir[u]);
  fir[u] = ecnt++;
  edg[ecnt] = eg(v, u, val, fir[v]);
  fir[v] = ecnt++;
}
int fa[N], dep[N], siz[N], son[N];
int tree[N << 2];
void dfs(int rt) {
  siz[rt] = 1, son[rt] = 0;
  for (int k = fir[rt]; k != -1; k = edg[k].nex) {
    if (edg[k].v != fa[rt]) {
      fa[edg[k].v] = rt;
      dep[edg[k].v] = dep[rt] + 1;
      dfs(edg[k].v);
      if (siz[edg[k].v] > siz[son[rt]]) son[rt] = edg[k].v;
      siz[rt] += siz[edg[k].v];
    }
  }
}
int w[N], top[N], cnt;
void dfs2(int rt, int tp) {
  w[rt] = ++cnt;
  top[rt] = tp;
  if (son[rt]) dfs2(son[rt], top[rt]);
  for (int k = fir[rt]; k != -1; k = edg[k].nex) {
    if (edg[k].v != son[rt] && edg[k].v != fa[rt]) {
      dfs2(edg[k].v, edg[k].v);
    }
  }
}
void update(int rt, int l, int r, int pos, int val) {
  if (l == r) {
    tree[rt] = val;
    return;
  }
  int mid = (l + r) >> 1;
  if (pos <= mid)
    update(rt << 1, l, mid, pos, val);
  else
    update(rt << 1 | 1, mid + 1, r, pos, val);
  tree[rt] = max(tree[rt << 1], tree[rt << 1 | 1]);
}
bool cmpid(eg a, eg b) { return a.id < b.id; }
void init() {
  memset(siz, 0, sizeof(siz));
  memset(tree, 0, sizeof(tree));
  root = (n + 1) / 2;
  fa[root] = cnt = dep[root] = 0;
  dfs(root);
  dfs2(root, root);
  for (int i = 1; i <= scnt; ++i) {
    if (dep[sav[i][0]] > dep[sav[i][1]]) swap(sav[i][0], sav[i][1]);
    update(1, 1, cnt, w[sav[i][1]], sav[i][2]);
  }
}
int maxi(int rt, int l, int r, int ql, int qr) {
  if (ql > r || qr < l) return 0;
  if (ql <= l && qr >= r) return tree[rt];
  int mid = (l + r) >> 1;
  return max(maxi(rt << 1, l, mid, ql, qr),
             maxi(rt << 1 | 1, mid + 1, r, ql, qr));
}
int Treemax(int va, int vb) {
  int f1 = top[va], f2 = top[vb], tmp = 0;
  while (f1 != f2) {
    if (dep[f1] < dep[f2]) {
      swap(f1, f2);
      swap(va, vb);
    }
    tmp = max(tmp, maxi(1, 1, cnt, w[f1], w[va]));
    va = fa[f1], f1 = top[va];
  }
  if (va == vb) return tmp;
  if (dep[va] > dep[vb]) swap(va, vb);
  return max(tmp, maxi(1, 1, cnt, w[son[va]], w[vb]));
}
int seed[N];
int find(int x) { return seed[x] < 0 ? x : seed[x] = find(seed[x]); }
int join(int a, int b) {
  a = find(a), b = find(b);
  if (a == b) return 0;
  if (seed[a] > seed[b])
    seed[b] += seed[a], seed[a] = b;
  else
    seed[a] += seed[b], seed[b] = a;
  return 1;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &MST[i].u, &MST[i].v, &MST[i].val);
    MST[i].id = i + 1;
  }
  sort(MST, MST + m);
  memset(seed, -1, sizeof(seed));
  memset(fir, -1, sizeof(fir));
  ecnt = scnt = 0;
  for (int i = 0; i < m; ++i) {
    if (join(MST[i].u, MST[i].v)) {
      ans[0] += MST[i].val;
      add(MST[i].u, MST[i].v, MST[i].val);
      sav[++scnt][0] = MST[i].u, sav[scnt][1] = MST[i].v,
      sav[scnt][2] = MST[i].val;
    }
  }
  init();
  for (int i = 0; i < m; ++i) {
    ans[MST[i].id] = ans[0] + MST[i].val - Treemax(MST[i].u, MST[i].v);
  }
  for (int i = 1; i <= m; ++i) {
    printf("%lld\n", ans[i]);
  }
}
