#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const int N = 10e5 + 1;
struct edge {
  int src, dst, weight;
  bool inMST;
  edge() = default;
  edge(int _src, int _dst, int _weight)
      : src{_src}, dst{_dst}, weight{_weight} {}
  friend ostream& operator<<(ostream& os, const edge& e) {
    os << "Edge : " << e.src << " -> " << e.dst << " (" << e.weight << ")";
    return os;
  }
  friend bool operator<(const edge& e1, const edge& e2) {
    return e1.weight < e2.weight;
  }
};
int parent_uf[N];
int subtree_size_uf[N];
void init(int n) {
  for (int i = 0; i < n; i++) {
    parent_uf[i] = i;
    subtree_size_uf[i] = 1;
  }
}
int root(int x) {
  return parent_uf[x] == x ? x : parent_uf[x] = root(parent_uf[x]);
}
void join(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  if (subtree_size_uf[x] < subtree_size_uf[y]) {
    parent_uf[x] = y;
    subtree_size_uf[y] += subtree_size_uf[x];
  } else {
    parent_uf[y] = x;
    subtree_size_uf[x] += subtree_size_uf[y];
  }
}
vector<edge> graph[N];
int depth[N];
int parent[N][20];
int parent_max[N][20];
void populate_mst_depths_dfs(int vertex = 1, int prev = -1,
                             int currentDepth = 0) {
  depth[vertex - 1] = currentDepth;
  for (size_t i = 0; i < graph[vertex].size(); ++i) {
    const edge& e = graph[vertex][i];
    if (!e.inMST || e.dst == prev) continue;
    parent[e.dst - 1][0] = e.src - 1;
    parent_max[e.dst - 1][0] = e.weight;
    populate_mst_depths_dfs(e.dst, vertex, currentDepth + 1);
  }
}
void preprocess(int n) {
  for (int i = 0; i < n; i++) {
    for (int j = 1; (1 << j) < n; j++) {
      parent[i][j] = -1;
      parent_max[i][j] = -1;
    }
  }
  for (int j = 1; (1 << j) < n; j++) {
    for (int i = 0; i < n; i++) {
      if (parent[i][j - 1] != -1) {
        parent[i][j] = parent[parent[i][j - 1]][j - 1];
        parent_max[i][j] =
            max(parent_max[i][j - 1], parent_max[parent[i][j - 1]][j - 1]);
      }
    }
  }
}
int lca2(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = log2(depth[u]); i >= 0; i--) {
    if (depth[u] - (1 << i) >= depth[v]) u = parent[u][i];
  }
  if (u == v) return u;
  for (int i = log2(depth[u]); i >= 0; i--)
    if (parent[u][i] != -1 && parent[u][i] != parent[v][i]) {
      u = parent[u][i];
      v = parent[v][i];
    }
  return parent[u][0];
}
int max_edge_lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int result = -1;
  for (int i = ceil(log2(depth[u])); i >= 0; i--) {
    if (depth[u] - (1 << i) >= depth[v]) {
      result = max(result, parent_max[u][i]);
      u = parent[u][i];
    }
  }
  if (u == v) return result;
  for (int i = ceil(log2(depth[u])); i >= 0; i--)
    if (parent[u][i] != -1 && parent[u][i] != parent[v][i]) {
      result = max(result, parent_max[u][i]);
      result = max(result, parent_max[v][i]);
      u = parent[u][i];
      v = parent[v][i];
    }
  result = max(result, parent_max[u][0]);
  result = max(result, parent_max[v][0]);
  return result;
}
int lca(int u, int v) { return lca2(u - 1, v - 1) + 1; }
int max_edge(int u, int v) { return max_edge_lca(u - 1, v - 1); }
int main() {
  int n, m;
  cin >> n >> m;
  vector<edge> edgeList;
  for (int i = 0; i < m; ++i) {
    edge e;
    cin >> e.src >> e.dst >> e.weight;
    edgeList.push_back(e);
  }
  vector<edge> unsortedEdgeList = edgeList;
  sort(edgeList.begin(), edgeList.end());
  init(n);
  ll weight = 0;
  for (edge& e : edgeList) {
    if (root(e.src) != root(e.dst)) {
      join(e.src, e.dst);
      e.inMST = true;
      weight += e.weight;
    } else {
      e.inMST = false;
    }
  }
  for (const edge& e : edgeList) {
    graph[e.src].push_back(e);
    edge otherEdge;
    otherEdge.src = e.dst;
    otherEdge.dst = e.src;
    otherEdge.inMST = e.inMST;
    otherEdge.weight = e.weight;
    graph[e.dst].push_back(otherEdge);
  }
  populate_mst_depths_dfs();
  preprocess(n);
  for (size_t i = 0; i < unsortedEdgeList.size(); ++i) {
    const edge& e = unsortedEdgeList[i];
    cout << weight + e.weight - max_edge(e.src, e.dst) << "\n";
  }
  return 0;
}
