#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int MAX = 2 * 1000 * 100 + 10;
const long long INF = 1e18;
const int MOD = 1e9 + 7;
long long n, m, x, y, z, root;
long long l, timer, in[MAX], out[MAX], up[MAX][20], mx[MAX][20];
vector<pair<long long, long long> > v[MAX];
void dfs(long long x, long long p, long long c) {
  in[x] = ++timer;
  up[x][0] = p;
  mx[x][0] = c;
  for (long long i = 1; i <= l; i++) {
    up[x][i] = up[up[x][i - 1]][i - 1];
    mx[x][i] = max(mx[x][i - 1], mx[up[x][i - 1]][i - 1]);
  }
  for (auto i : v[x]) {
    if (i.first != p) dfs(i.first, x, i.second);
  }
  out[x] = ++timer;
}
bool isparent(long long x, long long y) {
  return in[x] <= in[y] and out[x] >= out[y];
}
long long lca(long long x, long long y) {
  if (isparent(x, y)) return x;
  if (isparent(y, x)) return y;
  for (long long i = l; i >= 0; i--) {
    if (!isparent(up[x][i], y)) x = up[x][i];
  }
  return up[x][0];
}
long long maxi(long long x, long long y) {
  long long ans = 0;
  for (int g = 0; g < 2; g++) {
    for (int i = l; i >= 0; i--) {
      if (up[x][i] != -1 and !isparent(up[x][i], y)) {
        ans = max(ans, mx[x][i]);
        x = up[x][i];
      }
    }
    if (!isparent(x, y)) {
      ans = max(ans, mx[x][0]);
      x = up[x][0];
    }
    swap(x, y);
  }
  return ans;
}
void pre() {
  timer = 0;
  l = ceil(log2(n));
  dfs(root, root, 0);
}
long long par[MAX], siz[MAX];
void make() {
  for (long long i = 0; i < MAX; i++) {
    par[i] = i;
    siz[i] = 1;
  }
}
long long parent(long long x) {
  if (x == par[x]) return x;
  return par[x] = parent(par[x]);
}
void join(long long a, long long b) {
  a = parent(a);
  b = parent(b);
  if (a == b) return;
  if (siz[a] < siz[b]) swap(a, b);
  par[b] = a;
  siz[a] += siz[b];
}
long long xx[MAX], yy[MAX], wt[MAX], ar[MAX];
bool taken[MAX];
bool cmp(long long x, long long y) { return wt[x] < wt[y]; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> x >> y >> z;
    wt[i] = z;
    xx[i] = x;
    yy[i] = y;
  }
  make();
  for (long long i = 0; i < m; i++) ar[i] = i + 1;
  sort(ar, ar + m, cmp);
  long long ans = 0;
  for (long long i = 0; i < m; i++) {
    long long ind = ar[i];
    long long px = parent(xx[ind]);
    long long py = parent(yy[ind]);
    if (px == py) continue;
    taken[ind] = 1;
    ans += wt[ind];
    x = xx[ind];
    y = yy[ind];
    z = wt[ind];
    v[x].push_back(make_pair(y, z));
    v[y].push_back(make_pair(x, z));
    join(x, y);
    root = x;
  }
  pre();
  for (long long i = 1; i <= m; i++) {
    if (taken[i]) {
      cout << ans << '\n';
    } else {
      long long temp = ans + wt[i] - maxi(xx[i], yy[i]);
      cout << temp << '\n';
    }
  }
}
