#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2 * 1e5 + 5;
struct e {
  long long u, v, w;
};
bool operator<(const e& x, const e& y) { return x.w < y.w; }
long long n, m, mst_cost = 0;
long long par[MAXN], lab[MAXN];
long long p[MAXN][20], maxe[MAXN][20], h[MAXN];
vector<pair<long long, long long> > a[MAXN];
vector<e> MST;
vector<pair<e, long long> > edge;
vector<long long> res;
long long findSet(long long x) {
  return par[x] == x ? x : par[x] = findSet(par[x]);
}
void unionSet(long long x, long long y) {
  x = findSet(x);
  y = findSet(y);
  if (lab[x] < lab[y]) swap(x, y);
  par[y] = x;
  lab[x] += lab[y];
}
void dfs(long long u, long long pa) {
  for (long long i = 1; i <= 17; ++i) {
    p[u][i] = p[p[u][i - 1]][i - 1];
    maxe[u][i] = max(maxe[u][i - 1], maxe[p[u][i - 1]][i - 1]);
  }
  for (long long i = 0; i < a[u].size(); ++i) {
    long long v = a[u][i].first;
    if (v == pa) continue;
    h[v] = h[u] + 1;
    p[v][0] = u;
    maxe[v][0] = a[u][i].second;
    dfs(v, u);
  }
}
long long max_edge(long long u, long long v) {
  long long ans = 0;
  if (h[u] != h[v]) {
    if (h[u] < h[v]) swap(u, v);
    long long m = h[u] - h[v];
    for (long long i = 17; i >= 0; --i)
      if ((m & (1 << i)) > 0) {
        ans = max(ans, maxe[u][i]);
        u = p[u][i];
      }
    if (u == v) return ans;
  }
  for (long long i = 17; i >= 0; --i)
    if (p[u][i] != p[v][i]) {
      ans = max(ans, max(maxe[u][i], maxe[v][i]));
      u = p[u][i];
      v = p[v][i];
      return max(ans, max_edge(u, v));
    }
  return max(ans, max(maxe[u][0], maxe[v][0]));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) par[i] = i;
  edge.resize(m);
  res.resize(m);
  for (long long i = 0; i < m; ++i) {
    cin >> edge[i].first.u >> edge[i].first.v >> edge[i].first.w;
    edge[i].second = i;
  }
  sort(edge.begin(), edge.end());
  m = 0;
  while (MST.size() < n - 1) {
    long long x = edge[m].first.u;
    long long y = edge[m].first.v;
    long long W = edge[m].first.w;
    m++;
    if (findSet(x) == findSet(y)) continue;
    unionSet(x, y);
    mst_cost += W;
    MST.push_back(edge[m - 1].first);
    a[x].push_back(pair<long long, long long>(y, W));
    a[y].push_back(pair<long long, long long>(x, W));
  }
  h[1] = p[1][0] = 0;
  dfs(1, 0);
  for (long long i = 0; i < edge.size(); ++i) {
    res[edge[i].second] =
        mst_cost - max_edge(edge[i].first.u, edge[i].first.v) + edge[i].first.w;
  }
  for (long long i = 0; i < res.size(); ++i) cout << res[i] << "\n";
}
