#include <bits/stdc++.h>
using namespace std;
int n, m;
int a, b, c;
vector<pair<int, int> > v[200005], e[200005];
int p[200005];
int fin(int x) {
  if (p[x] != x) p[x] = fin(p[x]);
  return p[x];
}
void onion(int x, int y) {
  if (fin(x) == fin(y)) return;
  p[fin(y)] = fin(x);
}
priority_queue<pair<long long, pair<int, int> > > q;
int lca[200005][25], maxi[200005][25];
int depth[200005];
long long sum = 0;
long long cen[200005];
void dfs(int node, int prev) {
  for (auto it : e[node]) {
    if (it.first == prev) continue;
    depth[it.first] = depth[node] + 1;
    lca[it.first][0] = node;
    maxi[it.first][0] = it.second;
    dfs(it.first, node);
  }
}
int plz(int x, int y) {
  if (depth[x] < depth[y]) swap(x, y);
  int res = 0;
  for (int i = 20; i >= 0; i--) {
    if (depth[x] - (1 << i) >= depth[y]) {
      res = max(res, maxi[x][i]);
      x = lca[x][i];
    }
  }
  if (x == y) return res;
  for (int i = 20; i >= 0; i--) {
    if (lca[x][i] != lca[y][i]) {
      res = max(res, maxi[x][i]);
      res = max(res, maxi[y][i]);
      x = lca[x][i];
      y = lca[y][i];
    }
  }
  res = max(res, maxi[x][0]);
  res = max(res, maxi[y][0]);
  return res;
}
pair<int, int> rr[200005];
map<pair<int, int>, int> mapa;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; m >= i; i++) {
    scanf("%d%d%d", &a, &b, &c);
    rr[i] = {a, b};
    cen[i] = c;
    v[a].push_back({b, c});
    v[b].push_back({a, c});
    q.push({-c, {a, b}});
  }
  for (int i = 1; n >= i; i++) p[i] = i;
  while (!q.empty()) {
    int cost = -q.top().first;
    int u = q.top().second.first;
    int uu = q.top().second.second;
    q.pop();
    if (fin(u) == fin(uu)) continue;
    onion(u, uu);
    e[u].push_back({uu, cost});
    e[uu].push_back({u, cost});
    mapa[{u, uu}] = 1;
    sum += cost;
  }
  dfs(1, -1);
  for (int j = 1; 20 >= j; j++)
    for (int i = 1; n >= i; i++) {
      lca[i][j] = lca[lca[i][j - 1]][j - 1];
      maxi[i][j] = max(maxi[i][j - 1], maxi[lca[i][j - 1]][j - 1]);
    }
  int qq;
  qq = m;
  for (int i = 1; m >= i; i++) {
    int a = rr[i].first;
    int b = rr[i].second;
    if (mapa[{a, b}] == 1) {
      printf("%lld\n", sum);
      continue;
    }
    long long wynik = 1LL * sum + cen[i] - plz(a, b);
    printf("%lld\n", wynik);
  }
}
