#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
long long int level[200001], parent[200001];
vector<vector<pair<long long int, long long int> > > arr(2 * 100001);
pair<long long int, long long int> ar[200001];
pair<long long int, pair<long long int, pair<long long int, long long int> > >
    edge[2 * 100001];
long long int lca[2 * 100001][20];
long long int maxlca[2 * 100001][20];
long long int n, m;
long long int freq[2 * 100001] = {0};
long long int ans[2 * 100001];
long long int root(long long int x) {
  if (ar[x].first != x) ar[x].first = root(ar[x].first);
  return ar[x].first;
}
void uni(long long int x, long long int y) {
  long long int p = root(x);
  long long int q = root(y);
  if (ar[p].second > ar[q].second) {
    ar[q].first = ar[p].first;
  } else if (ar[p].second < ar[q].second) {
    ar[p].first = ar[q].first;
  } else {
    ar[p].first = ar[q].first;
    ar[q].second++;
  }
}
void dfs(long long int u, long long int par) {
  for (auto v : arr[u]) {
    if (v.first != par) {
      level[v.first] = level[u] + 1;
      maxlca[v.first][0] = v.second;
      lca[v.first][0] = u;
      int j;
      for (j = 1; j <= 19; j++) {
        lca[v.first][j] = lca[lca[v.first][j - 1]][j - 1];
        maxlca[v.first][j] =
            max(maxlca[v.first][j - 1], maxlca[lca[v.first][j - 1]][j - 1]);
      }
      dfs(v.first, u);
    }
  }
}
long long int query(long long int p, long long int q) {
  long long int i;
  if (level[q] > level[p]) swap(p, q);
  long long int actual = p;
  long long int acc = q;
  int log;
  for (log = 1; (1 << log) <= level[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--) {
    if (level[p] - (1 << i) >= level[q]) p = lca[p][i];
  }
  long long int temp;
  if (p == q)
    temp = p;
  else {
    for (i = log; i >= 0; i--) {
      if (lca[p][i] != lca[q][i] and lca[p][i] != 0)
        p = lca[p][i], q = lca[q][i];
    }
    temp = lca[p][0];
  }
  long long int lol = 0;
  for (i = log; i >= 0; i--) {
    if (level[actual] - (1 << i) >= level[temp])
      lol = max(lol, maxlca[actual][i]), actual = lca[actual][i];
  }
  for (i = log; i >= 0; i--) {
    if (level[acc] - (1 << i) >= level[temp])
      lol = max(lol, maxlca[acc][i]), acc = lca[acc][i];
  }
  return lol;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int i, j;
  cin >> n >> m;
  for (i = 0; i <= n; i++) {
    ar[i] = make_pair(i, 0);
  }
  for (i = 0; i < m; i++) {
    long long int u, v, wt;
    cin >> u >> v >> wt;
    edge[i] = make_pair(wt, make_pair(u, make_pair(v, i)));
  }
  sort(edge, edge + m);
  long long int total = 0;
  for (i = 0; i < m; i++) {
    long long int u = edge[i].second.first;
    long long int v = edge[i].second.second.first;
    if (root(u) != root(v)) {
      uni(u, v);
      total += edge[i].first;
      freq[edge[i].second.second.second] = 1;
      arr[u].push_back(make_pair(v, edge[i].first)),
          arr[v].push_back(make_pair(u, edge[i].first));
    }
  }
  level[0] = -1;
  level[1] = 0;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= 19; j++) {
      lca[i][j] = 0;
      maxlca[i][j] = 0;
    }
  }
  level[1] = 0;
  dfs(1, -1);
  for (i = 0; i < m; i++) {
    long long int index = edge[i].second.second.second;
    if (freq[index] == 1)
      ans[index] = total;
    else {
      ans[index] = total -
                   query(edge[i].second.first, edge[i].second.second.first) +
                   edge[i].first;
    }
  }
  for (i = 0; i < m; i++) cout << ans[i] << "\n";
}
