#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U>& a) {
  out << "[" << a.first << " " << a.second << "]";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const vector<T>& a) {
  out << "[ ";
  for (auto& it : a) out << it << " ";
  out << "]";
  return out;
}
template <class T>
ostream& operator<<(ostream& out, const set<T>& a) {
  out << "[ ";
  for (auto& it : a) out << it << " ";
  out << "]";
  return out;
}
template <class T, class U>
ostream& operator<<(ostream& out, const map<T, U>& a) {
  for (auto& it : a) out << it.first << " -> " << it.second << " | ";
  return out;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;
const double eps = 1e-9;
long long expo(long long a, long long b, long long c = mod) {
  if (!b) return 1;
  long long temp = expo(a, b / 2, c);
  temp = (temp * temp) % c;
  if (b & 1) temp = (temp * a) % c;
  return temp;
}
class DSU {
 public:
  int par[N], rank[N];
  void init(int n) {
    for (int i = 0; i <= n; ++i) {
      par[i] = i;
      rank[i] = 1;
    }
  }
  int find(int x) {
    if (par[x] == x) return x;
    par[x] = find(par[x]);
    return par[x];
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] > rank[y]) swap(x, y);
    par[x] = y;
    rank[y] += rank[x];
  }
  bool same(int x, int y) { return find(x) == find(y); }
} d;
int id[N], dep[N];
long long ans[N];
vector<pair<int, int> > G[N];
int p[21][N], m[21][N];
pair<pair<int, int>, pair<int, int> > E[N];
void dfs(int node, int prev, int w = 0, int depth = 0) {
  p[0][node] = prev;
  m[0][node] = w;
  dep[node] = depth;
  for (auto it : G[node]) {
    if (it.first != prev) {
      dfs(it.first, node, it.second, depth + 1);
    }
  }
}
int func(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int diff = dep[u] - dep[v];
  int ans = 0;
  for (int i = 20; i >= 0; --i) {
    if ((1 << i) & diff) {
      ans = max(ans, m[i][u]);
      u = p[i][u];
    }
  }
  if (u == v) return ans;
  for (int i = 20; i >= 0; --i) {
    if (p[i][u] != p[i][v]) {
      ans = max({ans, m[i][u], m[i][v]});
      u = p[i][u];
      v = p[i][v];
    }
  }
  ans = max({ans, m[0][u], m[0][v]});
  return ans;
}
int main() {
  clock_t tm = clock();
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int __t = 1;
  for (int _t = 1; _t <= __t; ++_t) {
    int n, M;
    cin >> n >> M;
    for (int i = 0; i <= M - 1; ++i) {
      int u, v, w;
      cin >> u >> v >> w;
      u--, v--;
      E[i] = {{w, i}, {u, v}};
    }
    sort(E, E + M);
    d.init(n + 1);
    long long sum = 0;
    for (int i = 0; i <= M - 1; ++i) {
      int u = E[i].second.first, v = E[i].second.second;
      if (!d.same(u, v)) {
        d.unite(u, v);
        sum += E[i].first.first;
        id[E[i].first.second] = 1;
        G[u].push_back({v, E[i].first.first});
        G[v].push_back({u, E[i].first.first});
      }
    }
    memset(p, -1, sizeof(p));
    memset(m, 0, sizeof(m));
    dfs(0, -1);
    for (int i = 1; i <= 20; ++i) {
      for (int j = 0; j <= n - 1; ++j) {
        if (p[i - 1][j] != -1) {
          p[i][j] = p[i - 1][p[i - 1][j]];
          m[i][j] = max(m[i - 1][j], m[i - 1][p[i - 1][j]]);
        }
        m[i][j] = max(m[i][j], m[i - 1][j]);
      }
    }
    for (int i = 0; i <= M - 1; ++i) {
      if (id[E[i].first.second])
        ans[E[i].first.second] = sum;
      else {
        int u = E[i].second.first, v = E[i].second.second;
        ans[E[i].first.second] = sum - func(u, v) + E[i].first.first;
      }
    }
    for (int i = 0; i <= M - 1; ++i) {
      cout << ans[i] << "\n";
    }
  }
  tm = clock() - tm;
  cerr << (float)(tm) / CLOCKS_PER_SEC << "\n";
  return 0;
}
