#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
const ll mod = 1e9 + 7, inf = 1e18;
int n = 2e5 + 5, m, cur = 0;
ll tot = 0;
vvi el, orig;
vvvi adj(n);
vvi dp(n, vi(20));
vvi up(n, vi(20));
vi in(n), out(n), level(n);
struct dsu {
  vi p;
  dsu() {
    p.assign(n + 1, 0);
    for (int i = 0; i <= n; i++) p[i] = i;
  }
  int Find(int a) {
    if (p[a] == a) return a;
    return p[a] = Find(p[a]);
  }
  void Unite(int a, int b) {
    a = Find(a), b = Find(b);
    if (a == b) return;
    p[b] = a;
  }
};
bool cmp(vi& a, vi& b) { return a[2] < b[2]; }
bool is_anc(int u, int v) { return in[u] <= in[v] && out[u] >= out[v]; }
int lca(int u, int v) {
  if (is_anc(u, v)) return u;
  if (is_anc(v, u)) return v;
  if (in[v] < in[u]) swap(u, v);
  for (int i = 19; i >= 0; i--) {
    if (!is_anc(up[v][i], u)) v = up[v][i];
  }
  return up[v][0];
}
void dfs(int i, int p, int w) {
  in[i] = ++cur;
  level[i] = level[p] + 1;
  dp[i][0] = w;
  up[i][0] = p;
  for (int j = 1; j <= 19; j++) {
    up[i][j] = up[up[i][j - 1]][j - 1];
    dp[i][j] = max(dp[i][j - 1], dp[up[i][j - 1]][j - 1]);
  }
  for (auto e : adj[i]) {
    int curw = e[1], v = e[0];
    if (v == p) continue;
    dfs(v, i, curw);
  }
  out[i] = ++cur;
}
void inp() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    el.push_back({u, v, w});
    orig.push_back({u, v, w});
  }
  sort(el.begin(), el.end(), cmp);
  dsu val;
  for (vi e : el) {
    int u = e[0], v = e[1], w = e[2];
    if (val.Find(u) != val.Find(v)) {
      val.Unite(u, v);
      adj[u].push_back({v, w}), adj[v].push_back({u, w});
      tot += (ll)w;
    }
  }
  dfs(1, 1, 0);
}
int maxEdge(int u, int v) {
  int jump = level[u] - level[v];
  int ret = 0;
  for (int i = 19; i >= 0; i--) {
    if (jump & (1 << i)) {
      ret = max(ret, dp[u][i]);
      u = up[u][i];
    }
  }
  return ret;
}
void query() {
  for (auto it : orig) {
    int u = it[0], v = it[1], w = it[2];
    int l = lca(u, v);
    int val = max(maxEdge(u, l), maxEdge(v, l));
    cout << tot - (ll)val + (ll)w << endl;
  }
}
int main() {
  inp();
  query();
  return 0;
}
