#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int n, m, p[200005], par[18][200005], mn[18][200005], dist[200005];
long long ans[200005];
bool tree[200005];
vector<pair<int, int> > edge[200005];
struct dat {
  int u, v, w, id;
  dat() {}
  dat(int u, int v, int w, int id) : u(u), v(v), w(w), id(id) {}
  bool operator<(const dat& T) const { return w < T.w; }
} e[200005];
int find(int s) {
  if (s == p[s]) return s;
  return p[s] = find(p[s]);
}
void dfs(int id, int p, int lv, int cost) {
  par[0][id] = p;
  mn[0][id] = cost;
  dist[id] = lv;
  for (int i = 1; i < 18; i++) {
    par[i][id] = par[i - 1][par[i - 1][id]];
    mn[i][id] = max(mn[i - 1][id], mn[i - 1][par[i - 1][id]]);
  }
  for (int i = 0; i < edge[id].size(); i++) {
    int to = edge[id][i].first;
    if (to == p) continue;
    dfs(to, id, lv + 1, edge[id][i].second);
  }
}
int query(int x, int y) {
  if (dist[x] > dist[y]) swap(x, y);
  int cost = 0;
  for (int i = 0; i < 18; i++) {
    if ((dist[y] - dist[x]) & (1 << i)) {
      cost = max(cost, mn[i][y]);
      y = par[i][y];
    }
  }
  if (x == y) return cost;
  for (int i = 17; i >= 0; i--) {
    if (par[i][x] != par[i][y]) {
      cost = max(cost, mn[i][x]);
      x = par[i][x];
      cost = max(cost, mn[i][y]);
      y = par[i][y];
    }
  }
  cost = max(cost, mn[0][x]);
  cost = max(cost, mn[0][y]);
  return cost;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    p[i] = i;
  }
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    e[i] = dat(x, y, z, i);
  }
  sort(e, e + m);
  long long res = 0;
  for (int i = 0; i < m; i++) {
    int u = find(e[i].u);
    int v = find(e[i].v);
    if (u == v) continue;
    p[u] = v;
    res += e[i].w;
    edge[e[i].u].push_back({e[i].v, e[i].w});
    edge[e[i].v].push_back({e[i].u, e[i].w});
    tree[e[i].id] = 1;
  }
  dfs(1, 0, 0, 0);
  for (int i = 0; i < m; i++) {
    if (tree[e[i].id])
      ans[e[i].id] = res;
    else {
      int cost = query(e[i].u, e[i].v);
      ans[e[i].id] = res - cost + e[i].w;
    }
  }
  for (int i = 0; i < m; i++) printf("%lld\n", ans[i]);
}
