#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long M = 20;
class Edge {
 public:
  long long u, v, w, id;
  Edge(long long _u, long long _v, long long _w, long long _id) {
    u = _u;
    v = _v;
    w = _w;
    id = _id;
  }
};
vector<Edge> edge;
bool MST[N];
vector<pair<long long, long long> > G[N];
long long dsu[N], siz[N], up[N][M], dp[N][M], ans[N], tin[N], tout[N];
long long n, m, timer = 0;
long long root(long long u) {
  while (dsu[u] != u) {
    dsu[u] = dsu[dsu[u]];
    u = dsu[u];
  }
  return u;
}
void merge(long long u, long long v) {
  if (siz[u] < siz[v]) swap(u, v);
  dsu[v] = u;
  siz[u] += siz[v];
}
void DFS(long long u = 1, long long p = 1, long long w = 0) {
  tin[u] = ++timer;
  up[u][0] = p;
  dp[u][0] = w;
  for (long long i = 1; i < M; i++) {
    dp[u][i] = max(dp[u][i - 1], dp[up[u][i - 1]][i - 1]);
    up[u][i] = up[up[u][i - 1]][i - 1];
  }
  for (pair<long long, long long> child : G[u]) {
    long long v = child.first, w = child.second;
    if (v != p) DFS(v, u, w);
  }
  tout[u] = ++timer;
}
bool isAncestor(long long u, long long v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
long long LCA(long long u, long long v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  for (long long i = M - 1; i >= 0; i--) {
    if (!isAncestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
long long f(long long u, long long lca) {
  long long mx = 0;
  if (u == lca) return mx;
  for (long long i = M - 1; i >= 0; i--) {
    if (!isAncestor(up[u][i], lca)) {
      mx = max(mx, dp[u][i]);
      u = up[u][i];
    }
  }
  mx = max(mx, dp[u][0]);
  return mx;
}
void solve() {
  memset(MST, false, sizeof(MST));
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    dsu[i] = i;
    siz[i] = 1;
  }
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    edge.emplace_back(u, v, w, i);
  }
  sort((edge).begin(), (edge).end(),
       [&](Edge& a, Edge& b) { return a.w < b.w; });
  long long sum = 0;
  for (auto e : edge) {
    long long u = e.u, v = e.v, w = e.w, id = e.id;
    long long _u = root(u);
    long long _v = root(v);
    if (_u == _v) {
      continue;
    } else {
      merge(_u, _v);
      sum += w;
      MST[id] = true;
      G[u].push_back({v, w});
      G[v].push_back({u, w});
    }
  }
  DFS();
  for (auto e : edge) {
    long long u = e.u, v = e.v, w = e.w, id = e.id;
    if (MST[id])
      ans[id] = sum;
    else {
      long long lca = LCA(u, v);
      long long mx = max(f(u, lca), f(v, lca));
      ans[id] = sum + w - mx;
    }
  }
  for (long long i = 0; i < m; i++) cout << ans[i] << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
