#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200100;
int uf_parent[N];
int subtree_size[N];
void init(int n) {
  for (int i = 0; i < n; i++) {
    uf_parent[i] = i;
    subtree_size[i] = 1;
  }
}
int root(int x) {
  return uf_parent[x] == x ? x : uf_parent[x] = root(uf_parent[x]);
}
void join(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (subtree_size[x] < subtree_size[y]) {
    uf_parent[x] = y;
    subtree_size[y] += subtree_size[x];
  } else {
    uf_parent[y] = x;
    subtree_size[x] += subtree_size[y];
  }
}
struct edgeStruct {
  int u, v;
  ll w;
  int in;
  bool inMst;
};
bool operator<(const edgeStruct& a, const edgeStruct& b) { return a.w < b.w; }
bool inputorder(const edgeStruct& a, const edgeStruct& b) {
  return a.in < b.in;
}
edgeStruct edges[N];
vector<pair<int, ll>> mst_edges[N];
void add_mst_edge(edgeStruct& e) {
  mst_edges[e.u].emplace_back(e.v, e.w);
  mst_edges[e.v].emplace_back(e.u, e.w);
}
ll mst(int m) {
  sort(edges, edges + m);
  ll total_weight = 0;
  for (int i = 0; i < m; i++) {
    edgeStruct& e = edges[i];
    if (root(e.u) != root(e.v)) {
      total_weight += e.w;
      join(e.u, e.v);
      e.inMst = true;
      add_mst_edge(e);
    }
  }
  return total_weight;
}
pair<int, ll> par[N];
vector<pair<int, ll>> children[N];
int depth[N];
void constructMSTree(int c, int d, int cPar = -1, int w = -1) {
  par[c].first = cPar;
  par[c].second = w;
  depth[c] = d;
  for (pair<int, int> p : mst_edges[c]) {
    if (p.first == par[c].first) continue;
    constructMSTree(p.first, d + 1, c, p.second);
    children[c].emplace_back(p.first, p.second);
  }
}
const int logN = 50;
int parent[N][logN];
ll maxWeight[N][logN];
int log_[N];
void preprocess(int n) {
  for (int i = 1; i <= n; i++) parent[i][0] = par[i].first;
  for (int i = 1; i <= n; i++)
    for (int j = 1; (1 << j) < n; j++) parent[i][j] = -1;
  for (int j = 1; (1 << j) < n; j++)
    for (int i = 1; i <= n; i++)
      if (parent[i][j - 1] != -1)
        parent[i][j] = parent[parent[i][j - 1]][j - 1];
  int k = 0;
  int i = 1;
  while (i < n) {
    if ((1 << k) <= i && (1 << (k + 1)) > i) {
      log_[i] = k;
      ++i;
    } else
      ++k;
  }
}
void preprocessMaxWeight(int n) {
  for (int i = 1; i <= n; i++) maxWeight[i][0] = par[i].second;
  for (int i = 1; i <= n; i++)
    for (int j = 1; (1 << j) < n; j++) maxWeight[i][j] = -1;
  for (int j = 1; (1 << j) < n; j++)
    for (int i = 1; i <= n; i++)
      if (maxWeight[i][j - 1] != -1 && parent[i][j - 1] != -1)
        maxWeight[i][j] =
            max(maxWeight[i][j - 1], maxWeight[parent[i][j - 1]][j - 1]);
}
ll max_edge(int u, int v) {
  ll maxW = INT_MIN;
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = log_[depth[u]]; i >= 0; i--) {
    if (depth[u] - (1 << i) >= depth[v]) {
      maxW = max(maxW, maxWeight[u][i]);
      u = parent[u][i];
    }
  }
  if (u == v) return maxW;
  for (int i = log_[depth[u]]; i >= 0; i--)
    if (parent[u][i] != -1 && parent[u][i] != parent[v][i]) {
      maxW = max(maxW, max(maxWeight[u][i], maxWeight[v][i]));
      u = parent[u][i];
      v = parent[v][i];
    }
  maxW = max(maxW, max(maxWeight[u][0], maxWeight[v][0]));
  return maxW;
}
int main() {
  int n, m;
  cin >> n >> m;
  init(n + 10);
  for (int i = 0; i < m; i++) {
    cin >> edges[i].u >> edges[i].v >> edges[i].w;
    edges[i].in = i;
    edges[i].inMst = false;
  }
  ll mst_w = mst(m);
  constructMSTree(1, 0);
  preprocess(n);
  preprocessMaxWeight(n);
  sort(edges, edges + m, inputorder);
  for (int i = 0; i < m; i++) {
    if (edges[i].inMst) {
      cout << mst_w << '\n';
      continue;
    }
    ll max_edge_w = max_edge(edges[i].u, edges[i].v);
    cout << (mst_w - max_edge_w + edges[i].w) << '\n';
  }
  return 0;
}
