#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
int n, m;
int e[3][200005];
int b[200005];
vector<int> al[200005];
int p[200005];
int pr[19][200005];
int c[19][200005], mx;
int lv[200005];
int findp(int c) {
  if (p[c] == c) return c;
  return p[c] = findp(p[c]);
}
bool cmp(int &q1, int &q2) { return e[2][q1] < e[2][q2]; }
void dfs(int u, int par, int ls, int d = 1) {
  pr[0][u] = par;
  c[0][u] = ls;
  lv[u] = d;
  int i;
  for (i = 0; i < al[u].size(); i++) {
    int id = al[u][i];
    int v = (e[0][id] == u) ? e[1][id] : e[0][id];
    if (v == par) continue;
    dfs(v, u, e[2][id], d + 1);
  }
}
int get(int u, int v) {
  if (lv[u] > lv[v]) swap(u, v);
  int i;
  int rs = 0;
  for (i = mx - 1; i > -1 && lv[u] != lv[v]; i--) {
    if (lv[v] - (1 << i) >= lv[u]) {
      rs = max(rs, c[i][v]);
      v = pr[i][v];
    }
  }
  if (u == v) return rs;
  for (i = mx - 1; i > -1; i--) {
    if (pr[i][u] != -1 && pr[i][v] != -1 && pr[i][u] != pr[i][v]) {
      rs = max(rs, c[i][u]);
      rs = max(rs, c[i][v]);
      u = pr[i][u];
      v = pr[i][v];
    }
  }
  rs = max(rs, c[0][u]);
  rs = max(rs, c[0][v]);
  return rs;
}
int main() {
  int t, i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    for (j = 0; j < 3; j++) scanf("%d", &e[j][i]);
    b[i] = i;
    p[e[0][i]] = e[0][i];
    p[e[1][i]] = e[1][i];
  }
  sort(b, b + m, cmp);
  long long int sm = 0;
  for (i = 0; i < m; i++) {
    j = findp(e[0][b[i]]);
    k = findp(e[1][b[i]]);
    if (j != k) {
      p[j] = k;
      al[e[0][b[i]]].push_back(b[i]);
      al[e[1][b[i]]].push_back(b[i]);
      sm += e[2][b[i]];
    }
  }
  memset(pr, -1, sizeof(pr));
  dfs(1, -1, 0);
  for (j = 1; (1 << j) <= n; j++) {
    for (i = 1; i < n + 1; i++) {
      if (pr[j - 1][i] != -1) {
        pr[j][i] = pr[j - 1][pr[j - 1][i]];
        c[j][i] = max(c[j - 1][i], c[j - 1][pr[j - 1][i]]);
      } else
        c[j][i] = c[j - 1][i];
    }
  }
  mx = j;
  for (i = 0; i < m; i++) {
    printf("%lld\n", sm + e[2][i] - get(e[0][i], e[1][i]));
  }
  return 0;
}
