#include <bits/stdc++.h>
using namespace std;
vector<int> par, rnk, tin, tout;
vector<vector<int> > g;
vector<pair<long long, pair<int, int> > > ed;
set<pair<long long, pair<int, int> > > st;
long long p[200002][18], mx[200002][18];
int t, l = 18;
int get(int a) {
  if (par[a] == a) return a;
  return par[a] = get(par[a]);
}
void join(int a, int b) {
  if (rnk[a] > rnk[b]) swap(a, b);
  rnk[b] += (rnk[a] == rnk[b]);
  par[a] = b;
}
void dfs(int v, int w, long long q) {
  tin[v] = t++;
  mx[v][0] = q;
  p[v][0] = w;
  for (int j = 1; j < 18; j++) {
    p[v][j] = p[p[v][j - 1]][j - 1];
    mx[v][j] = max(mx[v][j - 1], mx[p[v][j - 1]][j - 1]);
  }
  for (int j = 0; j < g[v].size(); j += 2) {
    int u = g[v][j];
    if (u == w) continue;
    dfs(u, v, g[v][j + 1]);
  }
  tout[v] = t++;
}
bool anc(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (anc(a, b)) return a;
  if (anc(b, a)) return b;
  for (int j = 17; j >= 0; j--) {
    int c = p[a][j];
    if (!anc(c, b)) a = c;
  }
  return p[a][0];
}
long long get_mx(int a, int b) {
  long long val = 0;
  for (int j = 17; j >= 0; j--) {
    int c = p[b][j];
    if (anc(a, c)) {
      val = max(val, mx[b][j]);
      b = c;
    }
  }
  return val;
}
long long query(int a, int b) {
  int c = lca(a, b);
  return max(get_mx(c, a), get_mx(c, b));
}
int main() {
  long long n, m, v, u, w, sum = 0;
  cin >> n >> m;
  g.resize(n);
  tin.resize(n);
  tout.resize(n);
  rnk.resize(n, 0);
  par.resize(n);
  ed.resize(m);
  for (int j = 0; j < n; j++) {
    par[j] = j;
  }
  for (int j = 0; j < m; j++) {
    cin >> u >> v >> w;
    --u, --v;
    ed[j] = {w, {u, v}};
    st.insert(ed[j]);
  }
  while (!st.empty()) {
    auto pr = *st.begin();
    st.erase(st.begin());
    int a = pr.second.first, b = pr.second.second;
    u = get(a);
    v = get(b);
    if (u != v) {
      g[a].push_back(b);
      g[a].push_back(pr.first);
      g[b].push_back(a);
      g[b].push_back(pr.first);
      sum += pr.first;
      join(u, v);
    }
  }
  dfs(0, 0, 0);
  for (int j = 0; j < m; j++) {
    cout << sum - query(ed[j].second.first, ed[j].second.second) + ed[j].first
         << '\n';
  }
}
