#include <bits/stdc++.h>
using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
const long double PI = 3.141592653589793;
const long long INF = 9223372036854775807ll;
const long long mod = 1e9 + 7;
const int N = 2e5 + 2;
const int logN = 20;
vector<int> id(N), sz(N, 1);
int root(int v) {
  while (id[v] != v) {
    id[v] = id[id[v]];
    v = id[v];
  }
  return v;
}
int merge(int a, int b) {
  int p = root(a);
  int q = root(b);
  if (p == q) return 0;
  if (sz[p] > sz[q]) swap(p, q);
  sz[q] += sz[p];
  sz[p] = 0;
  id[p] = q;
  return 1;
}
vector<pair<int, int>> adj[N];
vector<int> lvl(N);
int par[N][logN];
int mxwt[N][logN];
void dfs(int u, int p) {
  for (auto v : adj[u])
    if (v.first != p) {
      lvl[v.first] = lvl[u] + 1;
      par[v.first][0] = u;
      mxwt[v.first][0] = v.second;
      dfs(v.first, u);
    }
}
int n, m;
void pre() {
  par[0][0] = 0;
  dfs(0, -1);
  for (int j = 1; j < logN; ++j) {
    for (int i = 0; i < n; ++i) {
      par[i][j] = par[par[i][j - 1]][j - 1];
      mxwt[i][j] = max(mxwt[i][j - 1], mxwt[par[i][j - 1]][j - 1]);
    }
  }
}
int calc(int u, int v) {
  int ans = 0;
  if (lvl[u] > lvl[v]) swap(u, v);
  int diff = lvl[v] - lvl[u];
  for (int j = 0; j < logN; ++j) {
    if ((1 << j) & diff) {
      ans = max(ans, mxwt[v][j]);
      v = par[v][j];
    }
  }
  if (u == v) return ans;
  for (int j = logN - 1; j >= 0; --j) {
    if (par[u][j] != par[v][j]) {
      ans = max({ans, mxwt[u][j], mxwt[v][j]});
      u = par[u][j];
      v = par[v][j];
    }
  }
  return max({ans, mxwt[u][0], mxwt[v][0]});
}
void solve() {
  for (int i = 0; i < N; ++i) {
    id[i] = i;
  }
  cin >> n >> m;
  vector<pair<pair<int, int>, pair<int, int>>> edges;
  for (int i = 0; i < m; ++i) {
    int v, u, w;
    cin >> u >> v >> w;
    u--;
    v--;
    edges.push_back({{w, i}, {u, v}});
  }
  sort(edges.begin(), edges.end());
  long long ans = 0;
  for (int i = 0; i < m; ++i) {
    if (merge(edges[i].second.first, edges[i].second.second)) {
      adj[edges[i].second.first].push_back(
          {edges[i].second.second, edges[i].first.first});
      adj[edges[i].second.second].push_back(
          {edges[i].second.first, edges[i].first.first});
      ans += edges[i].first.first;
    }
  }
  pre();
  vector<long long> pr(m, ans);
  for (int i = 0; i < m; ++i) {
    pr[edges[i].first.second] +=
        edges[i].first.first -
        calc(edges[i].second.first, edges[i].second.second);
  }
  for (long long x : pr) cout << x << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  solve();
  return 0;
}
