#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, pair<int, int> > g[200010];
set<int> s[200010];
int p[200010];
long long int ans[200010];
long long int res;
int root(int x) {
  if (x == p[x]) return x;
  return p[x] = root(p[x]);
}
void MST(int x, int y, int z) {
  x = root(x);
  y = root(y);
  if (x == y) return;
  res += z;
  if (s[x].size() > s[y].size()) swap(x, y);
  p[x] = y;
  while (!s[x].empty()) {
    set<int>::iterator it = s[x].begin();
    if (s[y].find(*it) != s[y].end()) {
      ans[*it] -= z;
    } else
      s[y].insert(*it);
    s[x].erase(it);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) p[i] = i;
  for (int i = 1; i <= m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    g[i].first = c;
    g[i].second.first = a;
    g[i].second.second = b;
    s[a].insert(i);
    s[b].insert(i);
    ans[i] = c;
  }
  sort(g + 1, g + m + 1);
  for (int i = 1; i <= m; ++i)
    MST(g[i].second.first, g[i].second.second, g[i].first);
  for (int i = 1; i <= m; ++i) cout << ans[i] + res << endl;
  return 0;
}
