#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, m;
struct E {
  int u, v, w, idx;
} edge[N];
bool choose[N];
int lg2[N];
long long ans[N];
bool cmp(const E& a, const E& b) { return a.w < b.w; }
int p[N];
int find(int x) {
  while (x != p[x]) p[x] = p[p[x]], x = p[x];
  return x;
}
vector<pair<int, int> > tree_edge[N];
int f[N][20], dep[N];
long long maxi[N][20];
void dfs(int u, int fa, int d) {
  f[u][0] = fa;
  dep[u] = d;
  for (int i = 0; i < (int)tree_edge[u].size(); i++) {
    int v = tree_edge[u][i].first;
    int w = tree_edge[u][i].second;
    if (v == fa) continue;
    maxi[v][0] = w;
    dfs(v, u, d + 1);
  }
}
long long go(int u, int v) {
  if (dep[u] > dep[v]) swap(u, v);
  int delta = dep[v] - dep[u];
  long long ret = -1;
  while (delta > 0) {
    ret = max(ret, maxi[v][lg2[delta]]);
    v = f[v][lg2[delta]];
    delta -= 1 << lg2[delta];
  }
  while (u != v) {
    int now = 0;
    while (f[u][now] != f[v][now]) now++;
    if (now) now--;
    ret = max(ret, maxi[u][now]);
    ret = max(ret, maxi[v][now]);
    u = f[u][now], v = f[v][now];
  }
  return ret;
}
int main() {
  lg2[0] = lg2[1] = 0;
  for (int i = 2; i <= 200000; i++) lg2[i] = lg2[i >> 1] + 1;
  while (~scanf("%d%d", &n, &m)) {
    memset(choose, false, sizeof(choose));
    for (int i = 0; i < m; i++) {
      scanf("%d%d%d", &edge[i].u, &edge[i].v, &edge[i].w);
      edge[i].idx = i;
    }
    sort(edge, edge + m, cmp);
    for (int i = 1; i <= n; i++) p[i] = i, tree_edge[i].clear();
    long long mst = 0;
    for (int i = 0; i < m; i++) {
      int u = edge[i].u;
      int v = edge[i].v;
      int w = edge[i].w;
      int fa = find(u);
      int fb = find(v);
      if (fa != fb) {
        mst += w;
        choose[edge[i].idx] = true;
        p[fb] = fa;
        tree_edge[u].push_back(make_pair(v, w));
        tree_edge[v].push_back(make_pair(u, w));
      }
    }
    memset(f, -1, sizeof(f)), memset(maxi, -1, sizeof(maxi));
    dfs(1, -1, 0);
    for (int i = 1; i <= 20; i++) {
      for (int u = 1; u <= n; u++) {
        if (f[u][i - 1] != -1) {
          f[u][i] = f[f[u][i - 1]][i - 1];
          if (f[u][i] != -1)
            maxi[u][i] = max(maxi[u][i - 1], maxi[f[u][i - 1]][i - 1]);
        }
      }
    }
    for (int i = 0; i < m; i++) {
      int idx = edge[i].idx;
      if (choose[idx] == false) {
        int u = edge[i].u;
        int v = edge[i].v;
        int w = edge[i].w;
        long long val = go(u, v);
        ans[idx] = mst + w - val;
      } else
        ans[idx] = mst;
    }
    for (int i = 0; i < m; i++) cout << ans[i] << endl;
  }
  return 0;
}
