#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int u;
  int v;
  int w;
  int id;
  bool operator<(const Edge& a) const { return (w > a.w); }
};
int root;
vector<int> depths;
vector<vector<int> > par;
vector<vector<int> > prop;
vector<vector<Edge> > adj;
const int NN = 18;
using ll = long long;
vector<ll> scores;
ll min_score;
int get_ancestor(int a, int depth) {
  int d = depths[a] - depth;
  int res = a;
  for (int i = 0; i < NN; ++i)
    if (d & (1 << i)) {
      res = par[res][i];
    }
  return res;
}
int lca(int a, int b) {
  if (depths[a] < depths[b]) b = get_ancestor(b, depths[a]);
  if (depths[b] < depths[a]) a = get_ancestor(a, depths[b]);
  if (a == b) return a;
  int left = 0;
  int right = depths[a];
  while (right > left + 1) {
    int mid = (left + right) / 2;
    int ca = get_ancestor(a, mid);
    int cb = get_ancestor(b, mid);
    if (ca != cb) {
      a = ca;
      b = cb;
      right = mid;
    } else {
      left = mid;
    }
  }
  int res = get_ancestor(a, left);
  return res;
}
int weight(int a, int b) {
  int d = depths[a] - depths[b];
  int res = 0;
  for (int i = 0; i < NN; ++i)
    if (d & (1 << i)) {
      res = max(res, prop[a][i]);
      a = par[a][i];
    }
  return res;
}
void build_mst() {
  int n = adj.size();
  depths.assign(n, -1);
  par.assign(n, vector<int>(NN, -1));
  prop.assign(n, vector<int>(NN, 0));
  vector<bool> visited(n, false);
  priority_queue<Edge> q;
  visited[root] = true;
  depths[root] = 0;
  for (Edge& e : adj[root]) q.push(e);
  min_score = 0;
  while (!q.empty()) {
    Edge e = q.top();
    q.pop();
    int cur = e.u;
    int next = e.v;
    if (visited[next]) continue;
    visited[next] = true;
    depths[next] = depths[cur] + 1;
    par[next][0] = cur;
    prop[next][0] = e.w;
    min_score += 1LL * e.w;
    for (Edge& ee : adj[next])
      if (!visited[ee.v]) q.push(ee);
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  sort(order.begin(), order.end(),
       [](const int a, const int b) { return (depths[a] < depths[b]); });
  for (int i = 1; i < NN; ++i) {
    int shift = (1 << i);
    for (int cur : order) {
      if (depths[cur] >= shift) {
        int next = par[cur][i - 1];
        par[cur][i] = par[next][i - 1];
        prop[cur][i] = max(prop[cur][i - 1], prop[next][i - 1]);
      }
    }
  }
}
void go_on() {
  for (vector<Edge>& ve : adj)
    for (Edge& e : ve)
      if (scores[e.id] == 0) {
        int a = e.u;
        int b = e.v;
        int l = lca(a, b);
        int la = weight(a, l);
        int lb = weight(b, l);
        int res = max(la, lb);
        scores[e.id] = min_score + 1LL * e.w - 1LL * res;
      }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  scores.assign(m, 0);
  adj.assign(n, vector<Edge>());
  for (int i = 0; i < m; ++i) {
    int ui, vi, wi;
    cin >> ui >> vi >> wi;
    --ui;
    --vi;
    if (vi < ui) swap(ui, vi);
    adj[ui].push_back(Edge{ui, vi, wi, i});
    adj[vi].push_back(Edge{vi, ui, wi, i});
  }
  root = 0;
  build_mst();
  go_on();
  for (int i = 0; i < m; ++i) {
    cout << scores[i] << '\n';
  }
  return 0;
}
