#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using sparse_table = vector<vector<int>>;
using graph = vector<vector<pair<int, int>>>;
struct dsu {
  vector<int> fa;
  dsu(int n) { fa.assign(n + 1, 0); }
  int find(int x) { return fa[x] ? fa[x] = find(fa[x]) : x; }
  bool unite(int x, int y) {
    if ((x = find(x)) != (y = find(y))) {
      fa[x] = y;
      return true;
    }
    return false;
  }
};
void dfs(int u, int p, int e, vector<int>& dist, graph const& g,
         sparse_table& lca, sparse_table& heavy) {
  dist[u] = dist[p] + 1;
  lca[0][u] = p;
  for (int i = 1; i < lca.size(); ++i) lca[i][u] = lca[i - 1][lca[i - 1][u]];
  heavy[0][u] = e;
  for (int i = 1; i < heavy.size(); ++i)
    heavy[i][u] = max(heavy[i - 1][u], heavy[i - 1][lca[i - 1][u]]);
  for (auto [v, w] : g[u]) {
    if (v != p) {
      dfs(v, u, w, dist, g, lca, heavy);
    }
  }
}
int query(int u, int v, vector<int> const& dist, sparse_table const& lca,
          sparse_table const& heavy) {
  int e = 0;
  if (dist[u] < dist[v]) swap(u, v);
  for (int d = dist[u] - dist[v]; d > 0; d -= d & -d) {
    int s = __builtin_ctz(d & -d);
    e = max(e, heavy[s][u]);
    u = lca[s][u];
  }
  int step = int(lca.size()) - 1;
  while (u != v) {
    while (step > 0 && lca[step][u] == lca[step][v]) step--;
    e = max({e, heavy[step][u], heavy[step][v]});
    u = lca[step][u];
    v = lca[step][v];
  }
  return e;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int, int>> edges(m);
  for (int i = 0; i < m; ++i) {
    int u, v, w;
    cin >> u >> v >> w;
    edges[i] = make_tuple(w, u, v, i + 1);
  }
  sort(edges.begin(), edges.end());
  dsu d(n + 1);
  graph g(n + 1);
  ll mst_cost = 0;
  for (auto& [w, u, v, idx] : edges) {
    if (d.unite(u, v)) {
      idx = -idx;
      mst_cost += w;
      g[u].emplace_back(v, w);
      g[v].emplace_back(u, w);
    }
  }
  int logn = 1;
  while ((1 << logn) <= n) logn++;
  vector<int> dist(n + 1);
  sparse_table lca(logn, vector<int>(n + 1));
  sparse_table heavy(logn, vector<int>(n + 1));
  dfs(1, 0, 0, dist, g, lca, heavy);
  vector<ll> ans(m);
  for (auto const [w, u, v, idx] : edges) {
    if (idx < 0)
      ans[-idx - 1] = mst_cost;
    else
      ans[idx - 1] = mst_cost + w - query(u, v, dist, lca, heavy);
  }
  for (auto x : ans) cout << x << '\n';
}
