#include <bits/stdc++.h>
using namespace std;
using LL = int64_t;
using pii = pair<int, int>;
const double PI = 2 * asin(1);
const int SZ = 2e5 + 10;
const int LOG_SZ = 20;
struct Edge {
  int u, v, w;
  Edge(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {}
  bool operator<(const Edge &e) const { return w > e.w; }
};
int g_n, g_m;
int depth[SZ], ppre[LOG_SZ][SZ], mmx[LOG_SZ][SZ];
vector<Edge> ve;
vector<vector<Edge>> vve;
bool vb[SZ];
priority_queue<Edge> pqe;
void pretreat() {}
void input() {
  memset(vb, 0, sizeof(vb));
  memset(depth, -1, sizeof(depth));
  memset(ppre, 0, sizeof(ppre));
  memset(mmx, 0, sizeof(mmx));
  ppre[0][1] = 1, mmx[0][1] = 0;
  ve.clear(), vve.clear(), vve.resize(g_n + 1);
  while (!pqe.empty()) {
    pqe.pop();
  }
  int u, v, w;
  for (int i = 0; i < g_m; ++i) {
    scanf(" %d %d %d", &u, &v, &w);
    ve.emplace_back(u, v, w);
    vve[u].emplace_back(u, v, w);
    vve[v].emplace_back(v, u, w);
  }
}
int dfs(int u) {
  if (depth[u] != -1) return depth[u];
  if (u == 1) return depth[u] = 0;
  return depth[u] = 1 + dfs(ppre[0][u]);
}
int LCA(int u, int v) {
  if (depth[u] > depth[v]) {
    swap(u, v);
  }
  for (int i = LOG_SZ - 1; i >= 0; --i) {
    if ((depth[v] - depth[u]) & (1 << i)) {
      v = ppre[i][v];
    }
  }
  if (u == v) return u;
  for (int i = LOG_SZ - 1; i >= 0; --i) {
    if (ppre[i][u] != ppre[i][v]) {
      u = ppre[i][u], v = ppre[i][v];
    }
  }
  return ppre[0][u];
}
int get_mx(int u, int p) {
  int mx = 0;
  for (int i = LOG_SZ - 1; i >= 0; --i) {
    if ((depth[u] - depth[p]) & (1 << i)) {
      mx = max(mx, mmx[i][u]);
      u = ppre[i][u];
    }
  }
  return mx;
}
void solve() {
  LL sum = 0;
  vb[1] = true;
  for (int i = 0; i < vve[1].size(); ++i) {
    pqe.emplace(vve[1][i]);
  }
  while (!pqe.empty()) {
    Edge e = pqe.top();
    pqe.pop();
    if (vb[e.v]) continue;
    ppre[0][e.v] = e.u;
    mmx[0][e.v] = e.w;
    sum += e.w;
    vb[e.v] = true;
    for (int i = 0; i < vve[e.v].size(); ++i) {
      pqe.emplace(vve[e.v][i]);
    }
  }
  ppre[0][1] = 1, mmx[0][1] = 0;
  for (int i = 1; i <= g_n; ++i) dfs(i);
  for (int i = 1; i < LOG_SZ; ++i) {
    for (int j = 1; j <= g_n; ++j) {
      ppre[i][j] = ppre[i - 1][ppre[i - 1][j]];
      mmx[i][j] = max(mmx[i - 1][j], mmx[i - 1][ppre[i - 1][j]]);
    }
  }
  for (Edge &e : ve) {
    int p = LCA(e.u, e.v);
    LL ans = sum + e.w - max(get_mx(e.u, p), get_mx(e.v, p));
    cout << ans << endl;
  }
}
int main() {
  pretreat();
  while (cin >> g_n >> g_m) {
    input();
    solve();
  }
  return 0;
}
