#include <bits/stdc++.h>
using namespace std;
long long n, m, res;
vector<pair<long long, pair<long long, long long> > > a;
pair<long long, long long> b[200005];
map<pair<long long, long long>, bool> ma1;
long long par[200005];
map<pair<long long, long long>, long long> ma;
vector<long long> a1[200005];
long long cha[22][200005];
long long mx[22][200005];
long long tr[200005];
long long h[200005];
void read() {
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long w;
    cin >> b[i].first >> b[i].second >> w;
    ma[make_pair(b[i].first, b[i].second)] = w;
    ma[make_pair(b[i].second, b[i].first)] = w;
    a.push_back(make_pair(w, make_pair(b[i].first, b[i].second)));
  }
}
long long fpar(long long u) {
  if (par[u] == 0) return u;
  par[u] = fpar(par[u]);
  return par[u];
}
void ghep(long long u, long long v) {
  if (par[u] > par[v]) swap(u, v);
  par[u] += par[v];
  par[v] = u;
}
void dfs(int u) {
  tr[u] = 1;
  for (int i = 0; i < a1[u].size(); i++) {
    int v = a1[u][i];
    if (tr[v]) continue;
    cha[0][v] = u;
    h[v] = h[u] + 1;
    dfs(v);
  }
}
void prepare() {
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      cha[i][j] = -1;
      mx[i][j] = -1e6;
    }
  }
  for (int i = 1; i <= n; i++) mx[0][i] = ma[make_pair(i, cha[0][i])];
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      if (cha[i - 1][j] != -1) {
        cha[i][j] = cha[i - 1][cha[i - 1][j]];
        mx[i][j] = max(mx[i - 1][cha[i - 1][j]], mx[i - 1][j]);
      }
    }
  }
}
long long lca(long long u, long long v) {
  long long resmax = -1e18;
  if (h[u] > h[v]) swap(u, v);
  for (long long i = 20; i >= 0; i--) {
    if (h[v] - (1 << i) >= h[u]) {
      resmax = max(resmax, mx[i][v]);
      v = cha[i][v];
    }
  }
  for (long long i = 20; i >= 0; i--) {
    if (cha[i][u] != -1 && cha[i][v] != cha[i][u]) {
      resmax = max(resmax, mx[i][v]);
      resmax = max(resmax, mx[i][u]);
      u = cha[i][u];
      v = cha[i][v];
    }
  }
  if (u != v) {
    resmax = max(resmax, mx[0][u]);
    resmax = max(resmax, mx[0][v]);
  }
  return resmax;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  read();
  sort(a.begin(), a.end());
  for (long long i = 0; i < a.size(); i++) {
    if (fpar(a[i].second.first) != fpar(a[i].second.second)) {
      ghep(fpar(a[i].second.first), fpar(a[i].second.second));
      res += a[i].first;
      ma1[make_pair(a[i].second.first, a[i].second.second)] = true;
      ma1[make_pair(a[i].second.second, a[i].second.first)] = true;
      a1[a[i].second.first].push_back(a[i].second.second);
      a1[a[i].second.second].push_back(a[i].second.first);
    }
  }
  dfs(1);
  prepare();
  for (long long i = 0; i < m; i++) {
    if (ma1[make_pair(b[i].first, b[i].second)] == true)
      cout << res << endl;
    else
      cout << res - lca(b[i].first, b[i].second) +
                  ma[make_pair(b[i].first, b[i].second)]
           << endl;
  }
  return 0;
}
