#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, long long int> > adj[200005];
map<pair<int, int>, int> edges;
map<pair<int, int>, long long int> wt;
vector<int> tree[200005];
int P[200005], L[200005];
int T[20][200005];
long long int M[20][200005];
long long int mst_wt;
void init() { return; }
void mst(int src) {
  mst_wt = 0;
  bool done[200005];
  memset(done, false, sizeof(done));
  done[src] = true;
  priority_queue<pair<long long int, pair<int, int> >,
                 vector<pair<long long int, pair<int, int> > >,
                 greater<pair<long long int, pair<int, int> > > >
      pq;
  for (auto it : adj[src]) {
    pq.push(make_pair(it.second, make_pair(src, it.first)));
  }
  while (!pq.empty()) {
    pair<long long int, pair<int, int> > p = pq.top();
    pq.pop();
    long long int w = p.first;
    int u = p.second.first;
    int v = p.second.second;
    if (done[v]) continue;
    tree[u].push_back(v);
    tree[v].push_back(u);
    mst_wt += w;
    done[v] = true;
    for (auto it : adj[v]) {
      pq.push(make_pair(it.second, make_pair(v, it.first)));
    }
  }
  return;
}
void bfs(int src) {
  vector<bool> visited(200005, false);
  visited[src] = true;
  P[src] = -1;
  L[src] = 0;
  queue<int> q;
  q.push(src);
  while (!q.empty()) {
    src = q.front();
    q.pop();
    for (auto it : tree[src]) {
      if (!visited[it]) {
        visited[it] = true;
        P[it] = src;
        L[it] = L[src] + 1;
        q.push(it);
      }
    }
  }
  return;
}
void preprocess() {
  for (int i = 0; i < 20; i++) {
    for (int j = 0; j < 200005; j++) {
      T[i][j] = -1;
      M[i][j] = 0;
    }
  }
  for (int j = 0; j < n; j++) {
    T[0][j] = P[j];
    if (P[j] != -1) M[0][j] = wt[make_pair(j, P[j])];
  }
  for (int i = 1; (1 << i) <= n; i++) {
    for (int j = 0; j < n; j++) {
      if (T[i - 1][j] != -1) {
        T[i][j] = T[i - 1][T[i - 1][j]];
        M[i][j] = max(M[i - 1][j], M[i - 1][T[i - 1][j]]);
      }
    }
  }
  return;
}
int lca(int u, int v) {
  if (L[u] < L[v]) {
    swap(u, v);
  }
  int log;
  for (log = 1; (1 << log) <= L[u]; log++)
    ;
  log--;
  for (int j = log; j >= 0; j--) {
    if (L[u] - (1 << j) >= L[v]) {
      u = T[j][u];
    }
  }
  if (u == v) return u;
  for (log = 1; (1 << log) <= L[u]; log++)
    ;
  log--;
  for (int j = log; j >= 0; j--) {
    if (T[j][u] != -1 && T[j][u] != T[j][v]) {
      u = T[j][u];
      v = T[j][v];
    }
  }
  return P[u];
}
int kanc(int u, int l) {
  int log;
  for (log = 1; (1 << log) <= L[u]; log++)
    ;
  log--;
  for (int j = log; j >= 0; j--) {
    if (L[u] - (1 << j) >= l) {
      u = T[j][u];
    }
  }
  return u;
}
long long int maxm(int v, int l) {
  int log;
  for (log = 1; (1 << log) <= L[v]; log++)
    ;
  log--;
  long long int ans = 0;
  for (int j = log; j >= 0; j--) {
    if (L[v] - (1 << j) >= L[l]) {
      ans = max(ans, M[j][v]);
      v = T[j][v];
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  init();
  cin >> n >> m;
  int u, v;
  long long int w;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    adj[u].push_back(make_pair(v, w));
    adj[v].push_back(make_pair(u, w));
    edges[make_pair(u, v)] = edges[make_pair(v, u)] = i;
    wt[make_pair(u, v)] = wt[make_pair(v, u)] = w;
  }
  mst(0);
  bfs(0);
  preprocess();
  long long int ans[200005];
  set<pair<int, int> > done;
  for (auto it : edges) {
    u = it.first.first;
    v = it.first.second;
    int idx = it.second;
    if (done.find(make_pair(u, v)) == done.end()) {
      int l = lca(u, v);
      if (l == u) {
        if (u == P[v])
          ans[idx] = mst_wt;
        else {
          long long int sub = maxm(v, u);
          ans[idx] = mst_wt - sub + wt[make_pair(u, v)];
        }
      } else if (l == v) {
        if (v == P[u])
          ans[idx] = mst_wt;
        else {
          int sub = maxm(u, v);
          ans[idx] = mst_wt - sub + wt[make_pair(u, v)];
        }
      } else {
        int sub1 = maxm(u, l);
        int sub2 = maxm(v, l);
        ans[idx] = mst_wt - max(sub1, sub2) + wt[make_pair(u, v)];
      }
      done.insert(make_pair(u, v));
      done.insert(make_pair(v, u));
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
