#include <bits/stdc++.h>
using namespace std;
int p[200005];
pair<pair<int, int>, pair<int, int> > ed[200005];
int sz[200005];
int pc[200005];
int d[200005];
int mpc[30][200005];
vector<pair<int, int> > G[200005];
int findp(int x) {
  if (p[x] == x) return x;
  return (p[x] = findp(p[x]));
}
int merge(int x, int y) {
  int a = findp(x);
  int b = findp(y);
  if (a == b) return 0;
  p[a] = b;
  return 1;
}
void dfs0(int x, int pre) {
  sz[x] = 1;
  for (auto i : G[x]) {
    if (i.first != pre) {
      dfs0(i.first, x);
      sz[x] += sz[i.first];
    }
  }
}
void dfs(int x, int pre, int h, int mn) {
  ;
  mpc[h][x] = mn;
  for (auto i : G[x]) {
    if (!pc[i.first] && i.first != pre) dfs(i.first, x, h, max(mn, i.second));
  }
}
void findcen(int x, int pre, int h) {
  for (auto i : G[x]) {
    if (sz[i.first] > sz[x] / 2 && !pc[i.first]) {
      sz[x] -= sz[i.first];
      sz[i.first] += sz[x];
      findcen(i.first, pre, h);
      return;
    }
  }
  pc[x] = pre;
  d[x] = h;
  ;
  dfs(x, -1, h, 0);
  for (auto i : G[x])
    if (!pc[i.first]) findcen(i.first, x, h + 1);
}
long long int ans[200005];
int main() {
  int n, m, i, j, a, b, w;
  cin >> n >> m;
  for (i = 1; i <= n; i++) p[i] = i;
  for (i = 0; i < m; i++) {
    cin >> a >> b >> w;
    ed[i].first.second = i;
    ed[i].second.first = a;
    ed[i].second.second = b;
    ed[i].first.first = w;
    ed[i].first.second = i;
  }
  sort(ed, ed + m);
  long long int cost = 0;
  for (i = 0; i < m; i++) {
    if (merge(ed[i].second.first, ed[i].second.second)) {
      G[ed[i].second.first].push_back(
          make_pair(ed[i].second.second, ed[i].first.first)),
          G[ed[i].second.second].push_back(
              make_pair(ed[i].second.first, ed[i].first.first)),
          cost += (long long int)ed[i].first.first, ed[i].first.first = -1;
    }
  }
  dfs0(1, 0);
  findcen(1, -1, 0);
  for (i = 0; i < m; i++) {
    long long int det;
    long long int temp = cost;
    if (ed[i].first.first == -1) {
      ans[ed[i].first.second] = cost;
      continue;
    };
    a = ed[i].second.first;
    b = ed[i].second.second;
    if (d[a] > d[b]) swap(a, b);
    while (d[a] < d[b]) b = pc[b];
    ;
    while (a != b) a = pc[a], b = pc[b];
    int l = d[a];
    ;
    det = max(mpc[l][ed[i].second.first], mpc[l][ed[i].second.second]);
    ;
    temp += (ed[i].first.first - det);
    ans[ed[i].first.second] = temp;
  }
  for (i = 0; i < m; i++) cout << ans[i] << "\n";
  return 0;
}
