#include <bits/stdc++.h>
using namespace std;
template <typename T>
T sqr(T x) {
  return x * x;
}
const int maxn = 200003;
int par[maxn];
vector<pair<int, int> > g[maxn];
int tin[maxn], tout[maxn];
bool used[maxn];
int pr[20][maxn];
int pathcost[20][maxn];
long long ans[maxn];
int getpar(int x) {
  if (x == par[x]) return x;
  return par[x] = getpar(par[x]);
}
void unite(int x, int y) {
  x = getpar(x), y = getpar(y);
  par[x] = y;
}
int timer = 0;
void dfs(int v) {
  used[v] = true;
  tin[v] = timer++;
  for (int i = 0; i < (int)g[v].size(); i++) {
    int to = g[v][i].first, cost = g[v][i].second;
    if (!used[to]) {
      dfs(to);
      pr[0][to] = v;
      pathcost[0][to] = cost;
    }
  }
  tout[v] = timer++;
}
bool isroot(int x, int y) { return tin[x] <= tin[y] && tout[y] <= tout[x]; }
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<pair<int, int>, pair<int, int> > > w;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    w.push_back(make_pair(make_pair(c, i), make_pair(x, y)));
  }
  sort(w.begin(), w.end());
  for (int i = 1; i <= n; i++) par[i] = i;
  long long treecost = 0;
  for (int i = 0; i < m; i++) {
    int x = w[i].second.first, y = w[i].second.second, cost = w[i].first.first;
    if (getpar(x) != getpar(y)) {
      treecost += cost;
      unite(x, y);
      g[x].push_back(make_pair(y, cost));
      g[y].push_back(make_pair(x, cost));
    }
  }
  dfs(1);
  pr[0][1] = 1;
  for (int i = 1; i < 20; i++) {
    for (int j = 1; j <= n; j++) {
      pr[i][j] = pr[i - 1][pr[i - 1][j]];
      pathcost[i][j] = max(pathcost[i - 1][j], pathcost[i - 1][pr[i - 1][j]]);
    }
  }
  for (int i = 0; i < m; i++) {
    int x = w[i].second.first, y = w[i].second.second, cost = w[i].first.first;
    int lcm = x;
    int firstmax = 0;
    for (int i = 19; i >= 0; i--)
      if (!isroot(pr[i][lcm], y)) {
        firstmax = max(firstmax, pathcost[i][lcm]);
        lcm = pr[i][lcm];
      }
    if (!isroot(lcm, y)) {
      firstmax = max(firstmax, pathcost[0][lcm]);
      lcm = pr[0][lcm];
    }
    lcm = y;
    int secondmax = 0;
    for (int i = 19; i >= 0; i--)
      if (!isroot(pr[i][lcm], x)) {
        secondmax = max(secondmax, pathcost[i][lcm]);
        lcm = pr[i][lcm];
      }
    if (!isroot(lcm, x)) {
      secondmax = max(secondmax, pathcost[0][lcm]);
      lcm = pr[0][lcm];
    }
    ans[w[i].first.second] = treecost - max(firstmax, secondmax) + cost;
  }
  for (int i = 0; i < m; i++) cout << ans[i] << "\n";
  return 0;
}
