#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int mod2 = 998244353;
long long exp(long long base, long long e, long long md) {
  long long mul = base % md;
  long long res = 1;
  while (e) {
    if (e & 1) res = (res * mul) % md;
    e >>= 1;
    mul = mul * mul % md;
  }
  return res;
}
const int N = 2e5 + 5;
const int L = 21;
struct E {
  int nxt, w;
};
struct Q {
  int a, b, w;
  bool operator<(const Q& o) const { return w < o.w; }
};
int par[N], sz[N];
int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }
bool comb(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return false;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  par[y] = x;
  return true;
}
vector<E> mst[N];
int mx[N][L];
int mst_par[N][L];
int level[N];
void dfs(int cur) {
  for (int i = 1; i < L; i++) {
    int p = mst_par[cur][i - 1];
    mst_par[cur][i] = mst_par[p][i - 1];
    mx[cur][i] = max(mx[cur][i - 1], mx[p][i - 1]);
  }
  for (E edge : mst[cur]) {
    int nxt = edge.nxt, w = edge.w;
    if (nxt == mst_par[cur][0]) continue;
    level[nxt] = level[cur] + 1;
    mst_par[nxt][0] = cur;
    mx[nxt][0] = w;
    dfs(nxt);
  }
}
int find_mx(int a, int b) {
  int ret = 0;
  if (level[a] < level[b]) swap(a, b);
  for (int i = L - 1; i >= 0; i--) {
    if (level[mst_par[a][i]] < level[b]) continue;
    ret = max(ret, mx[a][i]);
    a = mst_par[a][i];
  }
  if (a == b) return ret;
  for (int i = L - 1; i >= 0; i--) {
    if (mst_par[a][i] == mst_par[b][i]) continue;
    ret = max({ret, mx[a][i], mx[b][i]});
    a = mst_par[a][i], b = mst_par[b][i];
  }
  return max({ret, mx[a][0], mx[b][0]});
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < (N); i++) par[i] = i, sz[i] = 1;
  int n, m;
  cin >> n >> m;
  vector<Q> order(m);
  vector<Q> edges(m);
  for (int i = 0; i < (m); i++) {
    int a, b, w;
    cin >> a >> b >> w;
    order[i] = Q{a, b, w};
    edges[i] = Q{a, b, w};
  }
  sort((edges).begin(), (edges).end());
  long long tot = 0;
  for (int i = 0; i < (m); i++) {
    int a = edges[i].a, b = edges[i].b, w = edges[i].w;
    if (!comb(a, b)) continue;
    tot += w;
    mst[a].push_back(E{b, w});
    mst[b].push_back(E{a, w});
  }
  dfs(1);
  for (int i = 0; i < (m); i++) {
    int a = order[i].a, b = order[i].b, w = order[i].w;
    bool outside = mst_par[a][0] != b && mst_par[b][0] != a;
    cout << (outside ? tot + w - find_mx(a, b) : tot) << "\n";
  }
}
