#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;
int head[N], nxt[M], to[M], cst[M], ne, n;
void initT() {
  ne = 0;
  memset(head, -1, (n + 1) * sizeof head[0]);
}
void addEdge(int f, int t, int c) {
  to[ne] = t;
  cst[ne] = c;
  nxt[ne] = head[f];
  head[f] = ne++;
}
void addBiEdge(int a, int b, int c) {
  addEdge(a, b, c);
  addEdge(b, a, c);
}
int par[N], sz[N];
vector<pair<int, pair<int, int> > > edges;
void initMST() {
  fill(sz, sz + n + 1, 1);
  iota(par, par + n + 1, 0);
}
int find(int u) { return (u == par[u] ? u : par[u] = find(par[u])); }
bool merge(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return false;
  if (sz[u] > sz[v]) swap(u, v);
  sz[v] += sz[u];
  par[u] = par[v];
  return true;
}
long long sum;
void mst() {
  initMST();
  sort(edges.begin(), edges.end());
  for (auto t : edges)
    if (merge(t.second.first, t.second.second) == true)
      addBiEdge(t.second.first, t.second.second, t.first), sum += t.first;
}
int u[M], v[M], w[M], m;
int lev[N];
int sp[18][N];
int mx[18][N];
void dfs(int u = 1, int p = 0, int dep = 0, int c = 0) {
  lev[u] = dep;
  sp[0][u] = p;
  mx[0][u] = c;
  for (int e = head[u]; ~e; e = nxt[e]) {
    int v = to[e];
    if (v == p) continue;
    dfs(v, u, dep + 1, cst[e]);
  }
}
void buildSparse() {
  for (int j = 1; j <= 17; ++j)
    for (int i = 1; i <= n; ++i)
      sp[j][i] = sp[j - 1][sp[j - 1][i]],
      mx[j][i] = max(mx[j - 1][i], mx[j - 1][sp[j - 1][i]]);
}
pair<int, int> getPth(int u, int p) {
  int ret = 0;
  for (int i = 17; ~i; --i)
    if (p & (1 << i)) ret = max(ret, mx[i][u]), u = sp[i][u];
  return make_pair(u, ret);
}
int getMx(int u, int v) {
  if (lev[u] < lev[v]) swap(u, v);
  auto p = getPth(u, lev[u] - lev[v]);
  u = p.first;
  if (u == v) return p.second;
  int ret = p.second;
  for (int i = 17; ~i; --i)
    if (sp[i][u] != sp[i][v])
      ret = max({ret, mx[i][u], mx[i][v]}), u = sp[i][u], v = sp[i][v];
  return max({ret, mx[0][u], mx[0][v]});
}
void solve() {
  dfs();
  buildSparse();
  for (int i = 0; i < m; ++i) printf("%lld\n", sum - getMx(u[i], v[i]) + w[i]);
}
int main() {
  scanf("%d%d", &n, &m);
  initT();
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", u + i, v + i, w + i);
    edges.emplace_back(make_pair(w[i], make_pair(u[i], v[i])));
  }
  mst();
  solve();
}
