#include <bits/stdc++.h>
const int MAXN = 2e5 + 100;
using namespace std;
struct edge {
  int c, a, b, ordem;
};
bool comp(struct edge x, struct edge y) { return x.c < y.c; }
int N, M;
long long MST = 0, ans[MAXN];
vector<pair<int, int> > adj[MAXN];
int pai[MAXN], peso[MAXN];
struct edge arestas[MAXN];
int dp[MAXN][20], nivel[MAXN], mm[MAXN][20];
long long resp;
int find(int x) {
  if (x == pai[x]) return x;
  return pai[x] = find(pai[x]);
}
void join(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (peso[x] > peso[y])
    pai[y] = x;
  else if (peso[x] < peso[y])
    pai[x] = y;
  else {
    peso[x]++;
    pai[y] = x;
  }
}
void kruskal() {
  for (int i = 1; i <= N; i++) {
    pai[i] = i;
    peso[i] = 1;
  }
  sort(arestas, arestas + M, comp);
  for (int i = 0; i < M; i++) {
    int a = arestas[i].a, b = arestas[i].b, c = arestas[i].c;
    if (find(a) != find(b)) {
      join(a, b);
      MST += c;
      adj[a].push_back(make_pair(b, c));
      adj[b].push_back(make_pair(a, c));
    }
  }
}
void ini() {
  for (int i = 2; i <= N; i++) pai[i] = -1;
  queue<int> fila;
  fila.push(1);
  pai[1] = nivel[1] = 1;
  while (!fila.empty()) {
    int x = fila.front();
    fila.pop();
    for (int i = 0; i < adj[x].size(); i++) {
      int v = adj[x][i].first;
      if (v != pai[x]) {
        nivel[v] = nivel[x] + 1;
        pai[v] = x;
        fila.push(v);
        mm[v][0] = adj[x][i].second;
      }
    }
  }
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= N; i++) dp[i][0] = pai[i];
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= N; i++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
  for (int j = 1; j < 20; j++)
    for (int i = 2; i <= N; i++) {
      if (dp[i][j - 1] == 1)
        mm[i][j] = mm[i][j - 1];
      else
        mm[i][j] = max(mm[i][j - 1], mm[dp[i][j - 1]][j - 1]);
    }
}
int LCA(int a, int b) {
  resp = -1 * 1LL;
  if (nivel[a] > nivel[b]) swap(a, b);
  for (int i = 20 - 1; i >= 0; i--) {
    if (nivel[b] - (1 << i) >= nivel[a]) {
      resp = max(resp, mm[b][i] * 1LL);
      b = dp[b][i];
    }
  }
  if (b == a) return a;
  for (int i = 20 - 1; i >= 0; i--) {
    if (dp[a][i] != 1 and dp[a][i] != dp[b][i]) {
      resp = max(resp, mm[a][i] * 1LL);
      resp = max(resp, mm[b][i] * 1LL);
      a = dp[a][i];
      b = dp[b][i];
    }
  }
  resp = max(resp, mm[a][0] * 1LL);
  resp = max(resp, mm[b][0] * 1LL);
  return dp[a][0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> arestas[i].a >> arestas[i].b >> arestas[i].c;
    arestas[i].ordem = i;
  }
  kruskal();
  ini();
  for (int i = 0; i < M; i++) {
    int a = arestas[i].a, b = arestas[i].b, c = arestas[i].c,
        ord = arestas[i].ordem;
    LCA(a, b);
    ans[ord] = MST + c - resp;
  }
  for (int i = 0; i < M; i++) cout << ans[i] << endl;
}
