#include <bits/stdc++.h>
using namespace std;
const int dx[] = {0, 1, -1, 0, 1, -1, -1, 1};
const int dy[] = {-1, 0, 0, 1, 1, 1, -1, -1};
const long long int MOD = 0;
const long long int N = 0;
struct e {
  int id;
  int u, v;
  long long int w;
  e() {}
  e(int a, int b, long long int c, int d) {
    u = a;
    v = b;
    w = c;
    id = d;
  }
  bool operator<(e other) const { return w < other.w; }
};
vector<e> a;
vector<pair<int, long long int> > g[200010];
int l[200010][19];
long long int mx[200010][19];
int n, m;
int pp[200010];
int h[200010], c[200010];
long long int saida[200010];
void dfs(int u, int pai, int cost) {
  h[u] = h[pai] + 1;
  c[u] = c[pai] + cost;
  l[u][0] = pai;
  mx[u][0] = cost;
  for (int i = 1; i < 19; i++) {
    l[u][i] = l[l[u][i - 1]][i - 1];
    mx[u][i] = max(mx[u][i - 1], mx[l[u][i - 1]][i - 1]);
  }
  int v, w;
  for (int i = 0; i < g[u].size(); i++) {
    v = g[u][i].first;
    w = g[u][i].second;
    if (v == pai) continue;
    dfs(v, u, w);
  }
}
int find(int u) {
  if (u == pp[u]) return u;
  return pp[u] = find(pp[u]);
}
bool same(int u, int v) { return find(u) == find(v); }
void join(int u, int v) { pp[find(u)] = find(v); }
int get(int u, int v) {
  if (h[v] > h[u]) swap(u, v);
  int dist = abs(h[u] - h[v]);
  long long int ans = -1e9 - 10LL;
  for (int i = 19 - 1; i >= 0; i--) {
    if (dist & (1 << i)) {
      ans = max(ans, mx[u][i]);
      u = l[u][i];
    }
  }
  if (u == v) return ans;
  for (int i = 19 - 1; i >= 0; i--) {
    if (l[u][i] != l[v][i]) {
      ans = max(ans, mx[u][i]);
      ans = max(ans, mx[v][i]);
      u = l[u][i];
      v = l[v][i];
    }
  }
  return max(max(mx[u][0], mx[v][0]), ans);
}
int main() {
  int u, v;
  long long int w;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    pp[i] = i;
  }
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    a.push_back(e(u, v, w, i));
  }
  sort(a.begin(), a.end());
  long long int total = 0LL;
  for (int i = 0; i < a.size(); i++) {
    u = a[i].u;
    v = a[i].v;
    w = a[i].w;
    if (!same(u, v)) {
      total += w;
      join(u, v);
      g[u].push_back(make_pair(v, w));
      g[v].push_back(make_pair(u, w));
    }
  }
  h[0] = -1;
  dfs(0, 0, 0);
  long long int aux;
  for (int i = 0; i < m; i++) {
    aux = total;
    total -= get(a[i].u, a[i].v);
    total += a[i].w;
    saida[a[i].id] = total;
    total = aux;
  }
  for (int i = 0; i < m; i++) {
    cout << saida[i] << "\n";
  }
  return 0;
}
