#include <bits/stdc++.h>
const int N = 200005, M = 20;
using namespace std;
int n, m, pr[N], par[M][N], mxe[M][N], dep[N];
long long ans[N];
vector<vector<int>> vi;
vector<pair<int, int>> g[N];
int f(int u) {
  if (u == pr[u]) return u;
  return pr[u] = f(pr[u]);
}
void dfs(int u, int prev) {
  dep[u] = dep[prev] + 1;
  for (auto el : g[u]) {
    int v = el.first;
    int w = el.second;
    if (v == prev) continue;
    dfs(v, u);
    par[0][v] = u;
    mxe[0][v] = w;
  }
}
int lca(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int ans = 0;
  for (int i = M - 1; i >= 0; i--) {
    if (dep[u] - (1 << i) >= dep[v]) {
      ans = max(ans, mxe[i][u]);
      u = par[i][u];
    }
  }
  if (u == v) return ans;
  for (int i = M - 1; i >= 0; i--) {
    if (par[i][u] != par[i][v]) {
      ans = max(ans, mxe[i][u]);
      ans = max(ans, mxe[i][v]);
      u = par[i][u];
      v = par[i][v];
    }
  }
  ans = max(ans, mxe[0][u]);
  ans = max(ans, mxe[0][v]);
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    vi.push_back({c, a, b, i});
    pr[a] = a;
    pr[b] = b;
  }
  long long sum = 0;
  sort(vi.begin(), vi.end());
  for (auto el : vi) {
    int a = el[1], b = el[2];
    int u = f(a), v = f(b);
    if (u == v)
      continue;
    else {
      pr[u] = v;
      g[a].push_back({b, el[0]});
      g[b].push_back({a, el[0]});
      sum += el[0];
    }
  }
  dfs(1, 0);
  for (int i = 1; i < M; i++) {
    for (int j = 1; j < N; j++) {
      par[i][j] = par[i - 1][par[i - 1][j]];
      mxe[i][j] = max(mxe[i - 1][j], mxe[i - 1][par[i - 1][j]]);
    }
  }
  for (auto el : vi) {
    int a = el[1], b = el[2];
    int l = lca(a, b);
    ans[el[3]] = sum + el[0] - l;
  }
  for (int i = 0; i < m; i++) cout << ans[i] << '\n';
  return 0;
}
