#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using edge_t = ll;
using pie = pair<int, edge_t>;
struct Edge {
  int u, v;
  edge_t w;
  bool operator<(const Edge& a) const { return (w < a.w); }
  bool operator>(const Edge& a) const { return (w > a.w); }
};
class UnionFind {
  vector<int> par;
  vector<int> sz;

 public:
  UnionFind() {}
  UnionFind(int n) { init(n); }
  void init(int n) {
    par.resize(n);
    sz.assign(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int get(int u) {
    if (par[u] == u) {
      return u;
    } else {
      return par[u] = get(par[u]);
    }
  }
  bool unite(int u, int v) {
    u = get(u);
    v = get(v);
    if (u == v) {
      return false;
    } else {
      if (sz[u] < sz[v]) {
        swap(u, v);
      }
      sz[u] += sz[v];
      par[v] = u;
      return true;
    }
  }
};
vector<int> mst_kruskal(int n, const vector<Edge>& edges) {
  int m = edges.size();
  vector<int> res(m, 0);
  vector<int> order(m);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(),
       [&edges](int a, int b) { return (edges[a].w < edges[b].w); });
  UnionFind uf(n);
  for (int i : order) {
    if (uf.unite(edges[i].u, edges[i].v)) {
      res[i] = 1;
    }
  }
  return res;
}
vector<int> mst_prim(int n, const vector<Edge>& edges) {
  int m = edges.size();
  vector<int> res(m, 0);
  vector<vector<pii>> adj(n, vector<pii>());
  for (int i = 0; i < m; ++i) {
    adj[edges[i].u].push_back(pii{edges[i].w, i});
    adj[edges[i].v].push_back(pii{edges[i].w, i});
  }
  priority_queue<pii, vector<pii>, greater<pii>> q;
  vector<int> visited(n, 0);
  visited[0] = 1;
  for (pii& p : adj[0]) q.push(p);
  while (!q.empty()) {
    pii p = q.top();
    q.pop();
    int u = edges[p.second].u;
    int v = edges[p.second].v;
    if (visited[v]) swap(u, v);
    if (visited[v]) continue;
    visited[v] = 1;
    res[p.second] = 1;
    for (pii& pp : adj[v]) {
      const Edge& e = edges[pp.second];
      if (!visited[e.u] || !visited[e.v]) {
        q.push(pp);
      }
    }
  }
  return res;
}
template <int NN>
class LCA {
 public:
  vector<vector<pie>> adj;
  vector<int> depths;
  vector<vector<int>> par;
  vector<vector<edge_t>> prop;
  void dfs(int u) {
    for (int i = 1; i < NN && par[u][i - 1] != -1; ++i) {
      int tmp = par[u][i - 1];
      par[u][i] = par[tmp][i - 1];
      prop[u][i] = max(prop[u][i - 1], prop[tmp][i - 1]);
    }
    for (pie& p : adj[u])
      if (depths[p.first] == -1) {
        depths[p.first] = depths[u] + 1;
        par[p.first][0] = u;
        prop[p.first][0] = p.second;
        dfs(p.first);
      }
  }
  void init(int n, const vector<Edge>& edges) {
    depths.assign(n, -1);
    adj.assign(n, vector<pie>());
    par.assign(n, vector<int>(NN, -1));
    prop.assign(n, vector<edge_t>(NN, 0));
    for (const Edge& e : edges) {
      adj[e.u].push_back(pie{e.v, e.w});
      adj[e.v].push_back(pie{e.u, e.w});
    }
  }
  void build(int root) {
    depths[root] = 0;
    dfs(root);
  }
  int get_ancestor(int u, int h) {
    int dh = depths[u] - h;
    if (dh > 0) {
      for (int i = NN - 1; i >= 0; --i) {
        if (dh >= (1 << i)) {
          dh -= (1 << i);
          u = par[u][i];
        }
      }
    }
    return u;
  }
  edge_t get_ancestor_prop(int u, int h) {
    int dh = depths[u] - h;
    edge_t res = 0;
    if (dh > 0) {
      for (int i = NN - 1; i >= 0; --i) {
        if (dh >= (1 << i)) {
          dh -= (1 << i);
          res = max(res, prop[u][i]);
          u = par[u][i];
        }
      }
    }
    return res;
  }
  int get_lca(int u, int v) {
    if (depths[u] > depths[v]) {
      swap(u, v);
    }
    v = get_ancestor(v, depths[u]);
    if (u == v) {
      return u;
    }
    for (int i = NN - 1; i >= 0; --i) {
      int au = par[u][i];
      int av = par[v][i];
      if ((au != -1) && (av != -1) && (au != av)) {
        u = au;
        v = av;
      }
    }
    int res = par[u][0];
    return res;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  vector<Edge> edges;
  edges.reserve(m);
  for (int i = 0; i < m; ++i) {
    int ui, vi, wi;
    cin >> ui >> vi >> wi;
    --ui;
    --vi;
    edges.push_back(Edge{ui, vi, wi});
  }
  vector<int> used = mst_prim(n, edges);
  ll tot = 0LL;
  vector<Edge> edges2;
  edges2.reserve(m);
  for (int i = 0; i < m; ++i)
    if (used[i]) {
      tot += edges[i].w;
      edges2.push_back(edges[i]);
    }
  LCA<20> lca;
  lca.init(n, edges2);
  lca.build(0);
  for (int i = 0; i < m; ++i) {
    if (used[i]) {
      cout << tot << '\n';
    } else {
      int u = edges[i].u;
      int v = edges[i].v;
      int l = lca.get_lca(u, v);
      ll w = max(lca.get_ancestor_prop(u, lca.depths[l]),
                 lca.get_ancestor_prop(v, lca.depths[l]));
      ll res = tot + 1LL * edges[i].w - 1LL * w;
      cout << res << '\n';
    }
  }
  return 0;
}
