#include <bits/stdc++.h>
using namespace std;
long long n, m, mn = 0, u[200005], v[200005], w[200005];
long long par[200005][21], p[200005], parent[200005], h[200005];
long long check[200005], rmq[200005][21];
vector<pair<long, long long> > adj[200005];
priority_queue<pair<long long, pair<long long, long long> >,
               vector<pair<long long, pair<long long, long long> > >,
               greater<pair<long long, pair<long long, long long> > > >
    pq;
long find(int i) {
  if (parent[i] == i) {
    return i;
  } else {
    return parent[i] = find(parent[i]);
  }
}
void uni(long x, long y) {
  long parx = find(x);
  long pary = find(y);
  parent[parx] = pary;
}
void dfs(int i) {
  check[i] = 1;
  for (int j = 0; j < adj[i].size(); j++) {
    if (check[adj[i][j].first] == 0) {
      check[adj[i][j].first] = 1;
      p[adj[i][j].first] = i;
      h[adj[i][j].first] = h[i] + 1;
      rmq[adj[i][j].first][0] = adj[i][j].second;
      dfs(adj[i][j].first);
    }
  }
}
long long lon(int a, int b) {
  long u = a, v = b;
  long long mx = 0;
  if (h[u] < h[v]) {
    swap(u, v);
  }
  for (int i = 19; i >= 0; i--) {
    if (h[u] - (1 << i) >= h[v]) {
      mx = max(mx, rmq[u][i]);
      u = par[u][i];
    }
  }
  if (u == v) {
    return mx;
  } else {
    for (int i = 19; i >= 0; i--) {
      if (par[u][i] != par[v][i] && par[u][i] != -1 && par[v][i] != -1) {
        mx = max(mx, max(rmq[u][i], rmq[v][i]));
        u = par[u][i];
        v = par[v][i];
      }
    }
    mx = max(mx, max(rmq[u][0], rmq[v][0]));
    return mx;
  }
}
int main() {
  scanf("%ld %ld", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%ld %ld %lld", &u[i], &v[i], &w[i]);
    pq.push(make_pair(w[i], make_pair(u[i], v[i])));
  }
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
    p[i] = i;
  }
  while (pq.size() > 0) {
    if (find(pq.top().second.first) != find(pq.top().second.second)) {
      mn = mn + pq.top().first;
      uni(pq.top().second.first, pq.top().second.second);
      adj[pq.top().second.first].push_back(
          make_pair(pq.top().second.second, pq.top().first));
      adj[pq.top().second.second].push_back(
          make_pair(pq.top().second.first, pq.top().first));
    }
    pq.pop();
  }
  dfs(1);
  p[1] = -1;
  memset(par, -1, sizeof par);
  for (int i = 1; i <= n; i++) {
    par[i][0] = p[i];
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      if (par[i][j - 1] != -1) {
        par[i][j] = par[par[i][j - 1]][j - 1];
        rmq[i][j] = max(rmq[i][j - 1], rmq[par[i][j - 1]][j - 1]);
      }
    }
  }
  for (int i = 1; i <= m; i++) {
    printf("%lld\n", mn + w[i] - lon(u[i], v[i]));
  }
}
