#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int LG = 18;
int from[N], to[N], cost[N];
bool cmp(int x, int y) { return cost[x] < cost[y]; }
int root[N], sz[N];
long long res[N];
int getRoot(int x) {
  if (x != root[x]) {
    root[x] = getRoot(root[x]);
  }
  return root[x];
}
void unite(int x, int y) {
  x = getRoot(x);
  y = getRoot(y);
  if (sz[x] > sz[y]) {
    root[y] = x;
    sz[x] += sz[y];
  } else {
    root[x] = y;
    sz[y] += sz[x];
  }
}
int euler[2 * N];
int mx[N][LG], prv[N][LG];
int tin[N], tout[N];
int depth[N], eup[N];
vector<pair<int, int>> edge[N];
int fr = 0;
void dfs(int x, int p) {
  depth[x] = depth[p] + 1;
  fr++;
  tin[x] = fr;
  euler[fr] = x;
  mx[x][0] = eup[x];
  prv[x][0] = p;
  for (int i = 1; i < LG; i++) {
    prv[x][i] = prv[prv[x][i - 1]][i - 1];
    mx[x][i] = max(mx[x][i - 1], mx[prv[x][i - 1]][i - 1]);
  }
  for (auto &it : edge[x]) {
    if (it.first != p) {
      eup[it.first] = it.second;
      dfs(it.first, x);
      ++fr;
      euler[fr] = x;
    }
  }
  tout[x] = fr;
}
int getBst(int x, int canGo) {
  int have = 0;
  int ret = 0;
  for (int i = LG - 1; i >= 0; i--) {
    if (canGo & (1 << i)) {
      ret = max(ret, mx[x][i]);
      x = prv[x][i];
    }
  }
  return ret;
}
int aint[8 * N];
int combine(int x, int y) {
  if (depth[x] < depth[y]) {
    return x;
  }
  return y;
}
void build(int p, int l, int r) {
  if (l == r) {
    aint[p] = euler[l];
    return;
  }
  int m = (l + r) >> 1;
  build(2 * p, l, m);
  build(2 * p + 1, m + 1, r);
  aint[p] = combine(aint[2 * p], aint[2 * p + 1]);
}
int query(int p, int l, int r, int ql, int qr) {
  if (r < ql || l > qr) {
    return 0;
  }
  if (ql <= l && r <= qr) {
    return aint[p];
  }
  int m = (l + r) >> 1;
  return combine(query(2 * p, l, m, ql, qr),
                 query(2 * p + 1, m + 1, r, ql, qr));
}
bool used[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    from[i] = x;
    to[i] = y;
    cost[i] = c;
  }
  vector<int> edges;
  for (int i = 1; i <= m; i++) {
    edges.emplace_back(i);
  }
  sort(edges.begin(), edges.end(), cmp);
  for (int i = 1; i <= n; i++) {
    root[i] = i;
    sz[i] = 1;
  }
  long long ans = 0;
  for (auto &it : edges) {
    if (getRoot(from[it]) != getRoot(to[it])) {
      ans += cost[it];
      unite(from[it], to[it]);
      edge[from[it]].push_back({to[it], cost[it]});
      edge[to[it]].push_back({from[it], cost[it]});
      used[it] = true;
    }
  }
  dfs(1, 0);
  build(1, 1, fr);
  depth[0] = n + 5;
  for (int i = 1; i <= m; i++) {
    if (used[i]) {
      res[i] = ans;
    } else {
      int l = tin[from[i]];
      int r = tout[to[i]];
      if (l > r) {
        swap(l, r);
      }
      int lca = query(1, 1, fr, l, r);
      res[i] = ans + cost[i] -
               max(getBst(from[i], depth[from[i]] - depth[lca]),
                   getBst(to[i], depth[to[i]] - depth[lca]));
    }
    cout << res[i] << '\n';
  }
  return 0;
}
