#include <bits/stdc++.h>
using namespace std;
int n, m, p[200005], size[200005];
struct edge {
  int i;
  int a, b, c;
} edges[200005];
bool used[200005];
long long ans[200005];
int find(int i) {
  if (p[i] == i) return i;
  return p[i] = find(p[i]);
}
bool connect(int a, int b) {
  a = find(a), b = find(b);
  if (a == b) return false;
  if (size[a] > size[b]) swap(a, b);
  p[a] = b;
  size[b] += size[a];
  return true;
}
bool cmp(const edge &a, const edge &b) { return a.c < b.c; }
vector<pair<int, int> > adjl[200005];
int par[200005][20], wei[200005][20];
int depth[200005];
void dfs(int i) {
  for (int j = 1; j < 20; j++) {
    par[i][j] = par[par[i][j - 1]][j - 1];
    wei[i][j] = max(wei[i][j - 1], wei[par[i][j - 1]][j - 1]);
  }
  for (int j = 0; j < ((int)(adjl[i]).size()); j++) {
    int g = adjl[i][j].first;
    if (par[i][0] == g) continue;
    depth[g] = depth[i] + 1;
    par[g][0] = i;
    wei[g][0] = adjl[i][j].second;
    dfs(g);
  }
}
int hi(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  int hia = 0, hib = 0;
  for (int i = 20 - 1; i >= 0; i--)
    if (depth[par[a][i]] >= depth[b]) {
      hia = max(hia, wei[a][i]);
      a = par[a][i];
    }
  if (a == b) return hia;
  for (int i = 20 - 1; i >= 0; i--)
    if (par[a][i] != par[b][i]) {
      hia = max(hia, wei[a][i]);
      a = par[a][i];
      hib = max(hib, wei[b][i]);
      b = par[b][i];
    }
  hia = max(hia, wei[a][0]);
  hib = max(hib, wei[b][0]);
  return max(hia, hib);
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    p[i] = i;
    size[i] = 1;
  }
  for (int i = 1; i <= m; i++) {
    edge &e = edges[i];
    e.i = i;
    scanf("%d %d %d", &e.a, &e.b, &e.c);
  }
  sort(edges + 1, edges + 1 + m, cmp);
  long long mst = 0;
  int got = 0;
  for (int i = 1; got != n - 1; i++)
    if (connect(edges[i].a, edges[i].b)) {
      edge &e = edges[i];
      mst += e.c;
      got++;
      used[e.i] = true;
      adjl[e.a].push_back(make_pair(e.b, e.c));
      adjl[e.b].push_back(make_pair(e.a, e.c));
    }
  depth[1] = 1;
  dfs(1);
  for (int i = 1; i <= m; i++) {
    int j = edges[i].i;
    if (used[j])
      ans[j] = mst;
    else
      ans[j] = mst - hi(edges[i].a, edges[i].b) + edges[i].c;
  }
  for (int i = 1; i <= m; i++) printf("%lld\n", ans[i]);
  return 0;
}
