#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, LG = 22;
int n, m, par[N], u[N], v[N], w[N], per[N], h[N];
long long sum;
struct sparse_table {
  int par = 0, mx = 0;
} sp[N][LG];
bool in[N];
vector<int> g[N];
int root(int x) { return par[x] = (par[x] == x ? x : root(par[x])); }
bool merge(int u, int v) {
  u = root(u), v = root(v);
  if (u == v) return false;
  par[u] = v;
  return true;
}
void dfs(int a, int ed = -1) {
  if (ed != -1) {
    int b = a ^ v[ed] ^ u[ed];
    h[a] = h[b] + 1;
    sp[a][0].par = b;
    sp[a][0].mx = w[ed];
    for (int i = 1; i < LG; i++) {
      sp[a][i].par = sp[sp[a][i - 1].par][i - 1].par;
      sp[a][i].mx = max(sp[a][i - 1].mx, sp[sp[a][i - 1].par][i - 1].mx);
    }
  }
  for (int i : g[a]) {
    if (i == ed) continue;
    int b = a ^ u[i] ^ v[i];
    dfs(b, i);
  }
}
int get(int v, int x, bool type) {
  int ret = 0;
  for (int i = 0; i < LG; i++)
    if (x >> i & 1) {
      ret = max(ret, sp[v][i].mx);
      v = sp[v][i].par;
    }
  return (type ? ret : v);
}
int get(int u, int v) {
  if (h[u] > h[v]) swap(u, v);
  int ret = get(v, h[v] - h[u], 1);
  v = get(v, h[v] - h[u], 0);
  if (v == u) return ret;
  for (int i = LG - 1; ~i; --i) {
    if (sp[v][i].par != sp[u][i].par) {
      ret = max({ret, sp[v][i].mx, sp[u][i].mx});
      v = sp[v][i].par;
      u = sp[u][i].par;
    }
  }
  ret = max({ret, sp[v][0].mx, sp[u][0].mx});
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--, v[i]--;
  }
  iota(par, par + n, 0);
  iota(per, per + m, 0);
  sort(per, per + m, [](int i, int j) { return w[i] < w[j]; });
  for_each(per, per + m, [](int i) {
    if (merge(u[i], v[i])) {
      sum += 1LL * w[i];
      in[i] = 1;
      g[u[i]].push_back(i);
      g[v[i]].push_back(i);
    }
  });
  dfs(0);
  for (int i = 0; i < m; i++) {
    if (in[i]) {
      cout << sum << "\n";
      continue;
    }
    cout << sum - 1LL * get(u[i], v[i]) + 1LL * w[i] << "\n";
  }
  return 0;
}
