#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(2e5) + 111;
long long total, ans[MAX_N];
struct edge {
  int u, v, cost, pos;
} edges[MAX_N];
int tin[MAX_N], tout[MAX_N], timer, up[MAX_N][22], mx[MAX_N][22], l, was[MAX_N],
    edge_weight, par[MAX_N], sz[MAX_N];
vector<pair<int, int>> g[MAX_N], gr[MAX_N];
void dfs(int v, int p, long long weight) {
  tin[v] = ++timer;
  up[v][0] = p;
  mx[v][0] = weight;
  for (int i = 1; i <= l; i++) {
    up[v][i] = up[up[v][i - 1]][i - 1];
    mx[v][i] = max(mx[v][i - 1], mx[up[v][i - 1]][i - 1]);
  }
  for (auto elem : gr[v]) {
    if (elem.first != p) dfs(elem.first, v, elem.second);
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }
int get(int x) {
  if (x == par[x]) return x;
  return par[x] = get(par[x]);
}
void join(int x, int y) {
  x = get(x);
  y = get(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  sz[x] += sz[y];
  par[y] = x;
}
int lca(int x, int y) {
  if (upper(x, y)) return x;
  if (upper(y, x)) return y;
  for (int i = l; i >= 0; i--) {
    if (!up[x][i]) continue;
    if (!upper(up[x][i], y)) x = up[x][i];
  }
  if (up[x][0] == 0) return x;
  return up[x][0];
}
int main() {
  int n, m, u, v, cost;
  memset(sz, 1, sizeof(sz));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &cost);
    g[u].emplace_back(v, cost);
    g[v].emplace_back(u, cost);
    edges[i].u = u;
    edges[i].v = v;
    edges[i].cost = cost;
    edges[i].pos = i;
  }
  sort(edges + 1, edges + m + 1,
       [](edge a, edge b) { return a.cost < b.cost; });
  for (int i = 1; i <= n; i++) par[i] = i;
  for (int i = 1; i <= m; i++) {
    int from = edges[i].u, to = edges[i].v, cost = edges[i].cost;
    if (get(from) != get(to)) {
      total += cost;
      was[edges[i].pos] = true;
      gr[from].emplace_back(to, cost);
      gr[to].emplace_back(from, cost);
      join(from, to);
    }
  }
  l = 1;
  while ((1 << l) <= n) l++;
  dfs(1, 0, 0);
  for (int i = 1; i <= m; i++) {
    if (was[edges[i].pos]) {
      ans[edges[i].pos] = total;
      continue;
    }
    int x = edges[i].u, y = edges[i].v, temp_res = 0;
    int pr = lca(x, y);
    if (pr == x || pr == y) {
      if (pr == x) {
        for (int j = l; j >= 0 && y != x; j--)
          if (up[y][j] && upper(x, up[y][j]))
            temp_res = max(temp_res, mx[y][j]), y = up[y][j];
        ans[edges[i].pos] = total - temp_res + edges[i].cost;
      } else {
        for (int j = l; j >= 0 && y != x; j--)
          if (up[x][j] && upper(y, up[x][j]))
            temp_res = max(temp_res, mx[x][j]), x = up[x][j];
        ans[edges[i].pos] = total - temp_res + edges[i].cost;
      }
    } else {
      for (int j = l; j >= 0 && y != pr; j--)
        if (up[y][j] && upper(pr, up[y][j]))
          temp_res = max(temp_res, mx[y][j]), y = up[y][j];
      for (int j = l; j >= 0 && x != pr; j--)
        if (up[x][j] && upper(pr, up[x][j]))
          temp_res = max(temp_res, mx[x][j]), x = up[x][j];
      ans[edges[i].pos] = total - temp_res + edges[i].cost;
    }
  }
  for (int i = 1; i <= m; i++) cout << ans[i] << "\n";
  return 0;
}
