#include <bits/stdc++.h>
using namespace std;
const int N = 2e5;
const int lg = 22;
int spt[2 * N + 100][lg], par[N + 100][lg], H[N + 100], E[2 * N + 100],
    L[2 * N + 100], Rank[N + 100];
int dept[2 * N + 100], vis[N + 100], mx[N + 100][lg], P[N + 100],
    rg[2 * N + 100], idx = 1;
vector<pair<int, int> > g[N + 100];
vector<pair<long, pair<int, int> > > edge1, edge2;
int find(int i) {
  if (P[i] == i) return i;
  return P[i] = find(P[i]);
}
bool sameset(int i, int j) { return (find(i) == find(j)); }
void dfs(int v, int dep, int p) {
  dept[v] = dep;
  H[v] = idx;
  L[idx] = dep;
  E[idx++] = v;
  for (auto it : g[v]) {
    if (it.first != p) {
      mx[it.first][0] = it.second;
      par[it.first][0] = v;
      dfs(it.first, dep + 1, v);
      E[idx] = v;
      L[idx++] = dep;
    }
  }
}
int getmin(int i, int j) {
  int l = min(i, j), r = max(i, j);
  int lr = rg[r - l + 1];
  if (L[spt[l][lr]] <= L[spt[r - (1 << lr) + 1][lr]])
    return spt[l][lr];
  else
    return spt[r - (1 << lr) + 1][lr];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    edge1.push_back(make_pair(w, make_pair(u, v)));
    edge2.push_back(make_pair(w, make_pair(u, v)));
  }
  sort(edge1.begin(), edge1.end());
  for (int i = 1; i <= n; i++) P[i] = i;
  for (int i = 0; (1 << i) <= 2 * N; i++) {
    rg[1 << i] = i;
  }
  for (int i = 1; i <= 2 * N; i++) {
    if (!rg[i]) rg[i] = rg[i - 1];
  }
  long long ans = 0;
  for (auto it : edge1) {
    int t1 = it.first;
    int u = it.second.first, v = it.second.second;
    if (!sameset(u, v)) {
      ans += t1;
      g[u].push_back(make_pair(v, t1));
      g[v].push_back(make_pair(u, t1));
      u = find(u);
      v = find(v);
      if (Rank[u] > Rank[v])
        P[v] = u;
      else {
        P[u] = v;
        if (Rank[u] == Rank[v]) Rank[v]++;
      }
    }
  }
  memset(dept, -1, sizeof dept);
  dfs(1, 0, 0);
  for (int j = 1; j < lg; j++) {
    for (int i = 1; i <= n; i++) {
      par[i][j] = par[par[i][j - 1]][j - 1];
      mx[i][j] = max(mx[i][j - 1], mx[par[i][j - 1]][j - 1]);
    }
  }
  for (int i = 1; i < 2 * n; i++) {
    spt[i][0] = i;
  }
  for (int j = 1; j < lg; j++) {
    for (int i = 1; i + (1 << j) - 1 < 2 * n; i++) {
      if (L[spt[i][j - 1]] <= L[spt[i + (1 << (j - 1))][j - 1]])
        spt[i][j] = spt[i][j - 1];
      else
        spt[i][j] = spt[i + (1 << (j - 1))][j - 1];
    }
  }
  for (auto it : edge2) {
    int u = it.second.first, v = it.second.second;
    int lcs = E[getmin(H[u], H[v])];
    int minus = 0;
    int cur = u;
    for (int i = lg - 1; i >= 0; i--) {
      if (dept[par[cur][i]] >= dept[lcs]) {
        minus = max(minus, mx[cur][i]);
        cur = par[cur][i];
      }
    }
    cur = v;
    for (int i = lg - 1; i >= 0; i--) {
      if (dept[par[cur][i]] >= dept[lcs]) {
        minus = max(minus, mx[cur][i]);
        cur = par[cur][i];
      }
    }
    printf("%lld\n", ans + it.first - minus);
  }
}
