#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<array<int, 4>> e;
int p[200005];
vector<pair<int, int>> adj[200005];
bool umst[200005];
int parent[200005][18];
int te[200005][18];
int d[200005];
long long sol[200005];
int find(int x) {
  if (p[x] == x) return x;
  return p[x] = find(p[x]);
}
bool spoji(int u, int v) {
  u = find(u);
  v = find(v);
  if (u != v) {
    p[v] = u;
    return true;
  }
  return false;
}
void dfs(int c, int prev, int w) {
  parent[c][0] = prev;
  te[c][0] = w;
  for (int i = 1; i < 18; i++) {
    parent[c][i] = parent[parent[c][i - 1]][i - 1];
    te[c][i] = max(te[c][i - 1], te[parent[c][i - 1]][i - 1]);
  }
  for (auto [nxt, we] : adj[c]) {
    if (nxt != prev) {
      d[nxt] = d[c] + 1;
      dfs(nxt, c, we);
    }
  }
}
int popni(int u, int g) {
  for (int i = 0; i < 18; i++) {
    if (g & (1 << i)) {
      u = parent[u][i];
    }
  }
  return u;
}
int lca(int u, int v) {
  if (d[u] < d[v]) swap(u, v);
  u = popni(u, d[u] - d[v]);
  if (u == v) return u;
  for (int i = 17; i >= 0; i--) {
    int u2 = parent[u][i];
    int v2 = parent[v][i];
    if (u2 != v2) {
      u = u2;
      v = v2;
    }
  }
  return parent[u][0];
}
int maksg(int c, int g) {
  int maks = -1;
  for (int i = 0; i < 18; i++) {
    if (g & (1 << i)) {
      maks = max(maks, te[c][i]);
      c = parent[c][i];
    }
  }
  return maks;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  e.resize(m);
  for (int i = 1; i <= n; i++) p[i] = i;
  for (int i = 0; i < m; i++) {
    cin >> e[i][1] >> e[i][2] >> e[i][0];
    e[i][3] = i;
  }
  sort(e.begin(), e.end());
  long long mst = 0;
  for (int i = 0; i < m; i++) {
    int u = e[i][1];
    int v = e[i][2];
    if (spoji(u, v)) {
      mst += e[i][0];
      adj[u].push_back({v, e[i][0]});
      adj[v].push_back({u, e[i][0]});
      umst[i] = true;
    }
  }
  dfs(1, 1, 0);
  for (int i = 0; i < m; i++) {
    if (!umst[i]) {
      int u = e[i][1];
      int v = e[i][2];
      int lc = lca(u, v);
      int ulc = maksg(u, d[u] - d[lc]);
      int vlc = maksg(v, d[v] - d[lc]);
      sol[e[i][3]] = mst - max(ulc, vlc) + e[i][0];
    } else
      sol[e[i][3]] = mst;
  }
  for (int i = 0; i < m; i++) {
    cout << sol[i] << "\n";
  }
  return 0;
}
