#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 10, MAX_LOG_N = 19;
int n, m;
long long sum;
int h[MAX_N];
int par[MAX_N];
pair<pair<int, int>, int> edge[MAX_N];
bool mark[MAX_N];
int PAR[MAX_LOG_N][MAX_N];
int mx[MAX_LOG_N][MAX_N];
vector<pair<int, int> > G[MAX_N];
vector<pair<int, int> > yal;
int root(int v) { return par[v] == v ? v : par[v] = root(par[v]); }
void dfs(int v = 0, int p = 0, int val = 0) {
  h[v] = 1 + h[p];
  PAR[0][v] = p;
  mx[0][v] = val;
  for (int i = 1; i < MAX_LOG_N; i++) {
    PAR[i][v] = PAR[i - 1][PAR[i - 1][v]];
    mx[i][v] = max(mx[i - 1][v], mx[i - 1][PAR[i - 1][v]]);
  }
  for (pair<int, int> u : G[v])
    if (u.first != p) dfs(u.first, v, u.second);
}
int get(int v, int u) {
  if (h[v] < h[u]) swap(v, u);
  int res = 0;
  int dis = h[v] - h[u];
  for (int i = 0; i < MAX_LOG_N; i++)
    if ((dis >> i) & 1) {
      res = max(res, mx[i][v]);
      v = PAR[i][v];
    }
  if (v == u) return res;
  for (int i = MAX_LOG_N - 1; ~i; i--)
    if (PAR[i][v] != PAR[i][u]) {
      res = max({res, mx[i][v], mx[i][u]});
      v = PAR[i][v];
      u = PAR[i][u];
    }
  return max({res, mx[0][v], mx[0][u]});
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u, w;
    cin >> edge[i].first.first >> edge[i].first.second >> edge[i].second;
    edge[i].first.first--, edge[i].first.second--;
  }
  for (int i = 0; i < m; i++) yal.push_back({edge[i].second, i});
  sort(yal.begin(), yal.end());
  for (int i = 0; i < n; i++) par[i] = i;
  for (pair<int, int> p : yal) {
    int id = p.second;
    if (root(edge[id].first.first) != root(edge[id].first.second)) {
      sum += edge[id].second;
      par[root(edge[id].first.first)] = root(edge[id].first.second);
      G[edge[id].first.first].push_back(
          {edge[id].first.second, edge[id].second});
      G[edge[id].first.second].push_back(
          {edge[id].first.first, edge[id].second});
      mark[id] = true;
    }
  }
  dfs();
  for (int i = 0; i < m; i++) {
    if (mark[i]) {
      cout << sum << "\n";
      continue;
    }
    cout << sum - get(edge[i].first.first, edge[i].first.second) +
                edge[i].second
         << "\n";
  }
  return 0;
}
