#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline bool chmin(T1 &a, T2 b) {
  return b < a && (a = b, true);
}
template <class T1, class T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}
using ll = long long;
struct UF {
  vector<int> parent, size;
  UF(int n) : parent(n), size(n, 1) {
    for (int i = (0); i < (n); i++) parent[i] = i;
  }
  int root(int x) {
    if (x == parent[x])
      return x;
    else
      return parent[x] = root(parent[x]);
  }
  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (size[x] < size[y]) swap(x, y);
    size[x] += size[y];
    parent[y] = x;
  }
  bool same(int x, int y) { return root(x) == root(y); }
};
struct edge {
  int to, cost;
};
struct ST {
  vector<int> seg;
  int size;
  ST(int n) {
    size = 1;
    while (size < n) size *= 2;
    seg.resize(size * 2);
  }
  void update(int k, int v) {
    k += size - 1;
    seg[k] = v;
    while (k > 0) {
      k = (k - 1) / 2;
      seg[k] = max(seg[k * 2 + 1], seg[k * 2 + 2]);
    }
  }
  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return seg[k];
    int x = query(a, b, k * 2 + 1, l, (l + r) / 2);
    int y = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return max(x, y);
  }
  int query(int a, int b) { return query(a, b, 0, 0, size); }
};
struct HL {
  vector<vector<int>> g, parent;
  vector<int> vid, depth, head, size;
  int u, v, k;
  HL(int n)
      : g(n),
        vid(n),
        depth(n),
        head(n),
        parent(24, vector<int>(n)),
        size(n, 1),
        k(0) {}
  void add(int u, int v) {
    g[u].push_back(v);
    g[v].push_back(u);
  }
  void build() {
    dfs(0, -1);
    dfs2(0, -1);
    for (int i = (0); i < (23); i++)
      for (int j = (0); j < (g.size()); j++) {
        if (parent[i][j] == -1)
          parent[i + 1][j] = -1;
        else
          parent[i + 1][j] = parent[i][parent[i][j]];
      }
  }
  void dfs(int curr, int prev) {
    head[curr] = curr;
    parent[0][curr] = prev;
    for (int &next : g[curr])
      if (next != prev) {
        depth[next] = depth[curr] + 1;
        dfs(next, curr);
        size[curr] += size[next];
        int &h = g[curr][0];
        if (h == prev || size[h] < size[next]) swap(h, next);
      }
  }
  void dfs2(int curr, int prev) {
    vid[curr] = k++;
    if (g[curr].size() > 1) head[g[curr][0]] = head[curr];
    for (int next : g[curr])
      if (next != prev) dfs2(next, curr);
  }
  int ancestor(int v, int k) {
    for (int i = (0); i < (24); i++)
      if (k & 1 << i) v = parent[i][v];
    return v;
  }
  int lca(int u, int v) {
    if (depth[u] < depth[v]) swap(u, v);
    u = ancestor(u, depth[u] - depth[v]);
    if (u == v) return u;
    for (int i = (24) - 1; i >= (0); i--)
      if (parent[i][u] != parent[i][v]) {
        u = parent[i][u];
        v = parent[i][v];
      }
    return parent[0][u];
  }
  void set(int x, int y) {
    u = x;
    v = y;
  }
  bool same(int u, int v) { return head[u] == head[v]; }
  pair<int, int> next() {
    if (depth[u] > depth[v]) swap(u, v);
    if (depth[head[u]] > depth[head[v]]) swap(u, v);
    int l = same(u, v) ? vid[u] : vid[head[v]], r = vid[v] + 1;
    v = same(u, v) ? -1 : parent[0][head[v]];
    return {l, r};
  }
  bool has_next() { return v != -1; }
};
vector<edge> g[202020];
int main() {
  int n, m;
  cin >> n >> m;
  vector<tuple<int, int, int>> es;
  for (int i = (0); i < (m); i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    u--;
    v--;
    es.emplace_back(w, u, v);
  }
  auto es2 = es;
  sort(es.begin(), es.end());
  UF uf(n);
  HL hl(n);
  ST st(n);
  ll mst = 0;
  for (int i = (0); i < (es.size()); i++) {
    int w, u, v;
    tie(w, u, v) = es[i];
    if (!uf.same(u, v)) {
      uf.merge(u, v);
      hl.add(u, v);
      g[u].push_back({v, w});
      g[v].push_back({u, w});
      mst += w;
    }
  }
  hl.build();
  for (int i = (0); i < (n); i++) {
    for (auto e : g[i])
      if (hl.depth[e.to] > hl.depth[i]) {
        st.update(hl.vid[e.to], e.cost);
      }
  }
  for (int i = (0); i < (es2.size()); i++) {
    int w, u, v;
    tie(w, u, v) = es2[i];
    ll mx = 0;
    int l = hl.lca(u, v);
    if (u != l) {
      int lu = hl.ancestor(u, hl.depth[u] - hl.depth[l] - 1);
      hl.set(u, lu);
      while (hl.has_next()) {
        int a, b;
        tie(a, b) = hl.next();
        chmax(mx, st.query(a, b));
      }
    }
    if (v != l) {
      int lv = hl.ancestor(v, hl.depth[v] - hl.depth[l] - 1);
      hl.set(v, lv);
      while (hl.has_next()) {
        int a, b;
        tie(a, b) = hl.next();
        chmax(mx, st.query(a, b));
      }
    }
    ll ans = mst + w - mx;
    printf("%I64d\n", ans);
  }
  return 0;
}
