#include <bits/stdc++.h>
using namespace std;
int scan_d() {
  register int c = getchar();
  int x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  return x;
}
long long scan_ll() {
  register long long c = getchar();
  long long x = 0;
  for (; (c < 48 || c > 57); c = getchar())
    ;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  return x;
}
int leader[200005];
list<pair<int, int> > adjlist[200005];
bool visited[200005];
bool mark[200005];
long long ans[200005];
int lev[200005];
int pred[200005];
int pedge[200005];
vector<pair<pair<int, int>, pair<int, int> > > edge;
int sz[200005];
int n;
void init(int n) {
  for (int i = 1; i <= n; i++) {
    leader[i] = i;
    sz[i] = 1;
  }
}
int getleader(int x) {
  int y = x;
  while (leader[y] != y) {
    y = leader[y];
  }
  while (leader[x] != x) {
    int t = x;
    x = leader[x];
    leader[t] = y;
  }
  return y;
}
void uni(int x, int y) {
  if (sz[x] > sz[y]) {
    leader[y] = x;
    sz[x] += sz[y];
  } else {
    leader[x] = y;
    sz[y] += sz[x];
  }
}
void dfs(int second) {
  visited[second] = 1;
  list<pair<int, int> >::iterator it;
  for (it = adjlist[second].begin(); it != adjlist[second].end(); it++) {
    if (!visited[it->first]) {
      lev[it->first] = lev[second] + 1;
      pred[it->first] = second;
      pedge[it->first] = it->second;
      dfs(it->first);
    }
  }
}
pair<int, int> dp[200005][20];
void preprocess() {
  for (int i = 1; i <= n; i++) {
    dp[i][0].first = pred[i];
    dp[i][0].second = pedge[i];
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      if (dp[i][j - 1].first) {
        dp[i][j].first = dp[dp[i][j - 1].first][j - 1].first;
        dp[i][j].second =
            max(dp[i][j - 1].second, dp[dp[i][j - 1].first][j - 1].second);
      }
    }
  }
}
pair<int, int> lca(int a, int b) {
  if (lev[a] < lev[b]) swap(a, b);
  int maxi = -1;
  while (lev[a] > lev[b]) {
    int x = log2(lev[a] - lev[b]);
    maxi = max(maxi, dp[a][x].second);
    a = dp[a][x].first;
  }
  if (a == b) return make_pair(a, maxi);
  for (int x = log2(lev[a]); x >= 0; x--) {
    if (dp[a][x].first && dp[a][x].first != dp[b][x].first) {
      maxi = max(maxi, dp[a][x].second);
      a = dp[a][x].first;
      maxi = max(maxi, dp[b][x].second);
      b = dp[b][x].first;
    }
  }
  return make_pair(pred[a], max(pedge[b], max(maxi, pedge[a])));
}
int main() {
  int m, i, j, k, w;
  long long mst = 0;
  scanf("%d %d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &j, &k, &w);
    edge.push_back(make_pair(make_pair(w, i), make_pair(j, k)));
  }
  init(n);
  sort((edge).begin(), (edge).end());
  vector<pair<pair<int, int>, pair<int, int> > >::iterator it;
  for (it = edge.begin(); it != edge.end(); it++) {
    int x = (it->second).first;
    int y = (it->second).second;
    i = getleader(x);
    j = getleader(y);
    if (i != j) {
      uni(i, j);
      mst += (long long)(it->first).first;
      adjlist[x].push_back(make_pair(y, (it->first).first));
      adjlist[y].push_back(make_pair(x, (it->first).first));
      mark[(it->first).second] = 1;
    }
  }
  dfs(1);
  preprocess();
  for (it = edge.begin(); it != edge.end(); it++) {
    if (mark[(it->first).second]) {
      ans[(it->first).second] = mst;
    } else {
      pair<int, int> pa;
      pa = lca((it->second).first, (it->second).second);
      ans[(it->first).second] =
          mst - (long long)pa.second + (long long)(it->first).first;
    }
  }
  for (i = 0; i < m; i++) {
    printf("%I64d\n", ans[i]);
  }
  return 0;
}
