#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int dx[8] = {+1, +1, +1, 0, 0, -1, -1, -1};
int dy[8] = {+1, 0, -1, +1, -1, +1, 0, -1};
long long power(long long x, long long y) {
  long long res = 1;
  x = x;
  while (y > 0) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long sqr(long long x) { return x * x; }
template <typename T>
T gcd(T a, T b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
template <class T>
inline void chmax(T &x, T y) {
  x = max((x), (y));
}
template <class T>
inline void chmin(T &x, T y) {
  x = min((x), (y));
}
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
template <typename T>
T powm(T a, T b, long long m) {
  T cnt = 1;
  while (b > 0) {
    if (b % 2 == 1) cnt = (cnt * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return cnt % m;
}
long long ncr(long long n, long long r) {
  long long res = 1;
  if (r > n) return 0;
  if (r > n - r) r = n - r;
  for (long long i = 0; i < r; i++) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
const int mod = 998244353;
const int N = 200005;
void prec() {}
long long n, m;
long long siz[N], par[N], u[N], v[N], w[N], cost, vis[N], level[N];
long long anc[N][21], weig[N][21];
map<long long, long long> mp[N];
vector<pair<long long, pair<long long, long long> > > edges;
vector<pair<long long, long long> > adms[N];
long long root(long long x) {
  return (par[x] == x) ? x : (par[x] = root(par[x]));
}
void unite(long long u, long long v) {
  if ((u = root(u)) == (v = root(v))) return;
  if (siz[u] > siz[v]) swap(u, v);
  siz[v] += siz[u];
  par[u] = v;
  siz[u] = 0;
}
void dfs(long long x, long long parr) {
  vis[x] = 1;
  level[x] = level[parr] + 1;
  anc[x][0] = parr;
  weig[x][0] = mp[x][parr];
  for (auto &it : adms[x]) {
    if (!vis[it.first]) dfs(it.first, x);
  }
}
long long lca(long long x, long long y) {
  if (level[x] < level[y]) swap(x, y);
  long long diff = level[x] - level[y];
  for (int i = 20; i >= 0; --i) {
    if ((1 << i) & diff) {
      x = anc[x][i];
    }
  }
  if (x == y) return x;
  for (int i = 20; i >= 0; --i) {
    if (anc[x][i] != anc[y][i]) {
      x = anc[x][i];
      y = anc[y][i];
    }
  }
  return anc[x][0];
}
void run() {
  cin >> n >> m;
  for (long long i = (1); i <= (n); ++i) par[i] = i, siz[i] = 1;
  for (long long i = (1); i <= (m); ++i) {
    cin >> u[i] >> v[i] >> w[i];
    edges.push_back(make_pair(w[i], make_pair(v[i], u[i])));
  }
  sort((edges).begin(), (edges).end());
  for (auto &it : edges) {
    long long uu = it.second.first;
    long long vv = it.second.second;
    if (root(uu) != root(vv)) {
      adms[uu].push_back(make_pair(vv, it.first));
      adms[vv].push_back(make_pair(uu, it.first));
      mp[uu][vv] = it.first;
      mp[vv][uu] = it.first;
      cost += it.first;
      unite(uu, vv);
    }
  }
  level[1] = 0;
  dfs(1, 1);
  for (int j = 1; j <= 20; ++j) {
    for (int i = 1; i <= n; ++i) {
      anc[i][j] = anc[anc[i][j - 1]][j - 1];
      weig[i][j] = max(weig[i][j - 1], weig[anc[i][j - 1]][j - 1]);
    }
  }
  for (int i = 1; i <= m; ++i) {
    long long x = u[i], y = v[i], wt = w[i];
    long long lc = lca(x, y);
    long long mx = -1000000000000000007;
    long long lvl1 = -level[lc] + level[x];
    for (int i = 20; i >= 0; --i) {
      if ((1 << i) & lvl1) {
        mx = max(weig[x][i], mx);
        x = anc[x][i];
      }
    }
    lvl1 = -level[lc] + level[y];
    for (int i = 20; i >= 0; --i) {
      if ((1 << i) & lvl1) {
        mx = max(weig[y][i], mx);
        y = anc[y][i];
      }
    }
    cout << cost - mx + wt << "\n";
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  int tc = 1;
  prec();
  for (long long i = 0; i < tc; ++i) run();
  return 0;
}
