#include <bits/stdc++.h>
using namespace std;
struct edge {
  int a, b, c, idx;
  bool operator<(const edge& rhs) const { return c < rhs.c; }
};
int n, m;
int fa[200010], w[200010];
edge E[200010];
vector<int> comp[200010];
vector<edge> adj[200010];
int getfa(int x) { return (x == fa[x]) ? x : fa[x] = getfa(fa[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &E[i].a, &E[i].b, &E[i].c);
    w[i] = E[i].c;
    E[i].idx = i;
    adj[E[i].a].push_back(E[i]);
    adj[E[i].b].push_back(E[i]);
  }
  sort(E, E + m);
  for (int i = 0; i <= n; i++) {
    fa[i] = i;
    comp[i].push_back(i);
  }
  long long mst = 0;
  for (int i = 0; i < m; i++) {
    int x = getfa(E[i].a);
    int y = getfa(E[i].b);
    if (x == y) continue;
    mst += E[i].c;
    if (comp[x].size() > comp[y].size()) swap(x, y);
    for (int j = 0; j < comp[x].size(); j++) {
      int u = comp[x][j];
      comp[y].push_back(u);
      for (int k = 0; k < adj[u].size(); k++) {
        int to = adj[u][k].b + adj[u][k].a - u;
        if (getfa(to) == y) w[adj[u][k].idx] -= E[i].c;
      }
    }
    fa[x] = y;
  }
  for (int i = 0; i < m; i++) printf("%I64d\n", mst + 1LL * w[i]);
  return 0;
}
