#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2e5 + 10;
const int MaxL = 18;
const int INF = 1e9;
int who[MaxN], dep[MaxN], n, m;
int x[MaxN], y[MaxN], c[MaxN];
vector<pair<int, int> > graph[MaxN];
int up[MaxN][MaxL], mxe[MaxN][MaxL];
int getWho(int v) { return v == who[v] ? v : who[v] = getWho(who[v]); }
void unite(int x, int y) {
  x = getWho(x);
  y = getWho(y);
  if ((x & 1) == 1) {
    swap(x, y);
  }
  who[x] = y;
}
void dfsLca(int v, int p, int ls) {
  up[v][0] = p;
  mxe[v][0] = ls;
  for (int i = 1; i < MaxL; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
    mxe[v][i] = max(mxe[v][i - 1], mxe[up[v][i - 1]][i - 1]);
  }
  for (int i = 0; i < (int)graph[v].size(); ++i) {
    int to = graph[v][i].first, len = graph[v][i].second;
    if (to == p) {
      continue;
    }
    dep[to] = dep[v] + 1;
    dfsLca(to, v, len);
  }
}
int getAns(int x, int y, int c) {
  if (up[x][0] == y || up[y][0] == x) {
    return 0;
  }
  if (dep[x] > dep[y]) {
    swap(x, y);
  }
  int ans = -1;
  for (int bit = MaxL - 1; bit >= 0; --bit) {
    if (dep[up[y][bit]] >= dep[x]) {
      ans = max(ans, mxe[y][bit]);
      y = up[y][bit];
    }
  }
  if (x != y) {
    for (int bit = MaxL - 1; bit >= 0; --bit) {
      if (up[x][bit] != up[y][bit]) {
        ans = max(ans, mxe[x][bit]);
        ans = max(ans, mxe[y][bit]);
        x = up[x][bit];
        y = up[y][bit];
      }
    }
    ans = max(ans, mxe[x][0]);
    ans = max(ans, mxe[y][0]);
  }
  ans = max(ans, 0);
  return c - ans;
}
int main() {
  scanf("%d%d", &n, &m);
  vector<pair<int, pair<int, int> > > edges;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d%d", &x[i], &y[i], &c[i]);
    x[i]--;
    y[i]--;
    edges.push_back(make_pair(c[i], make_pair(x[i], y[i])));
  }
  for (int i = 0; i < n; ++i) {
    who[i] = i;
  }
  sort(edges.begin(), edges.end());
  long long mst = 0;
  for (int i = 0; i < (int)edges.size(); ++i) {
    int x = edges[i].second.first, y = edges[i].second.second;
    int c = edges[i].first;
    if (getWho(x) != getWho(y)) {
      graph[x].push_back(make_pair(y, c));
      graph[y].push_back(make_pair(x, c));
      mst += c;
      unite(x, y);
    }
  }
  dfsLca(0, 0, -1);
  for (int i = 0; i < m; ++i) {
    cout << mst + getAns(x[i], y[i], c[i]) << '\n';
  }
  return 0;
}
