#include <bits/stdc++.h>
using namespace std;
const long long mxx = 2e5 + 5;
vector<long long> adj[mxx], span[mxx], back[mxx];
long long parent[mxx], level[mxx], s[mxx], ans[mxx], state[mxx];
map<pair<long long, long long>, long long> m;
set<pair<long long, long long>> st;
long long val;
long long spar[mxx][20], table[mxx][20];
struct edge {
  long long u, v, weight, ind;
};
bool comp(const edge &a, const edge &b) { return a.weight < b.weight; }
edge data[mxx];
long long find(long long u) {
  while (parent[u] != u) u = parent[u];
  return u;
}
void add(long long u, long long v) {
  u = find(u);
  v = find(v);
  if (s[u] > s[v]) swap(u, v);
  parent[u] = parent[v];
  s[v] += s[u];
}
void dfs(long long u) {
  state[u] = 1;
  for (auto x : adj[u]) {
    if (state[x] == 1) continue;
    if (state[x] == 2)
      back[x].push_back(u);
    else {
      if (!st.count({u, x})) continue;
      span[u].push_back(x);
      dfs(x);
    }
  }
}
void dfs1(long long u, long long par) {
  level[u] = level[par] + 1;
  spar[u][0] = par;
  table[u][0] = m[{u, par}];
  for (long long i = 1; i < 20; i++) {
    if (spar[u][i - 1] == 0) {
      spar[u][i] = 0;
      table[u][i] = 0;
    } else {
      spar[u][i] = spar[spar[u][i - 1]][i - 1];
      table[u][i] = max(table[u][i - 1], table[spar[u][i - 1]][i - 1]);
    }
  }
  for (auto x : span[u])
    if (x != par) dfs1(x, u);
}
long long lca(long long u, long long v) {
  long long df = level[u] - level[v];
  for (long long i = 19; i >= 0; i--) {
    long long num = 1 << i;
    if (num > df) continue;
    df -= num;
    u = spar[u][i];
  }
  if (u == v) return v;
  for (long long i = 19; i >= 0; i--) {
    long long num = 1 << i;
    if (spar[u][i] == spar[v][i])
      continue;
    else
      u = spar[u][i], v = spar[v][i];
  }
  return spar[u][0];
}
long long get(long long u, long long v) {
  long long df = level[u] - level[v];
  long long cur = 0;
  for (long long i = 19; i >= 0; i--) {
    long long num = 1 << i;
    if (num > df) continue;
    cur = max(cur, table[u][i]);
    u = spar[u][i];
    df -= num;
  }
  return cur;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, M;
  cin >> n >> M;
  for (long long i = 0; i < M; i++) {
    cin >> data[i].u >> data[i].v >> data[i].weight;
    data[i].ind = i;
    m[{data[i].u, data[i].v}] = data[i].weight;
    m[{data[i].v, data[i].u}] = data[i].weight;
    adj[data[i].u].push_back(data[i].v);
    adj[data[i].v].push_back(data[i].u);
  }
  sort(data, data + M, comp);
  val = 0;
  for (long long i = 1; i <= n; i++) {
    parent[i] = i;
    s[i] = 1;
  }
  for (long long i = 0; i < M; i++) {
    if (find(data[i].u) != find(data[i].v)) {
      st.insert({data[i].u, data[i].v});
      st.insert({data[i].v, data[i].u});
      add(data[i].u, data[i].v);
      val += data[i].weight;
    }
  }
  memset(state, 0, sizeof state);
  dfs(1);
  level[0] = 0;
  dfs1(1, 0);
  for (long long i = 0; i < M; i++) {
    long long u = data[i].u, v = data[i].v, w = data[i].weight,
              ind = data[i].ind;
    if (st.count({u, v}))
      ans[ind] = val;
    else {
      if (level[u] < level[v]) swap(u, v);
      long long ver = lca(u, v);
      ans[ind] = val + w - max(get(u, ver), get(v, ver));
    }
  }
  for (long long i = 0; i < M; i++) {
    cout << ans[i] << " ";
  }
}
