#include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T, typename T1>
void prin(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
template <typename T, typename T1>
void prin(set<pair<T, T1> >& a) {
  for (auto it = a.begin(); it != a.end(); it++) {
    cout << it->first << " " << it->second << "\n";
  }
}
template <typename T>
void prin(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i < a.size() - 1)
      cout << " ";
    else
      cout << "\n";
  }
}
template <typename T>
void prin(set<T>& a) {
  for (auto it = a.begin(); it != a.end(); it++) {
    cout << *it << " ";
  }
  cout << endl;
}
template <typename T>
void prin_new_line(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << "\n";
  }
}
template <typename T, typename T1>
void prin_new_line(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
int sum_vec(vector<int>& a) {
  int s = 0;
  for (int i = 0; i < a.size(); i++) {
    s += a[i];
  }
  return s;
}
template <typename T>
T max(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = max(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = min(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
double s_triangle(double x1, double y1, double x2, double y2, double x3,
                  double y3) {
  return abs(((x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)) / 2);
}
bool overflow(long long a, long long b) {
  if (a * b / b != a) return true;
  return false;
}
bool debug = 0;
const int maxn = 2e5 + 7;
long long mod = 1e9 + 7;
vector<pair<int, int> > g[maxn];
int parent[maxn];
int asdsad[maxn];
int find_parent(int v) {
  if (v == parent[v]) {
    return v;
  }
  return parent[v] = find_parent(parent[v]);
}
void union_set(int a, int b) {
  if (asdsad[a] < asdsad[b])
    swap(a, b);
  else if (asdsad[a] == asdsad[b])
    asdsad[a]++;
  parent[b] = a;
}
int l;
vector<int> up[maxn];
vector<int> mx[maxn];
int timer, tin[maxn], tout[maxn];
int deep[maxn];
void dfs(int v, int p, int dis) {
  tin[v] = ++timer;
  up[v][0] = p;
  mx[v][0] = dis;
  for (int i = 1; i <= l; i++) {
    up[v][i] = up[up[v][i - 1]][i - 1];
    mx[v][i] = max(mx[up[v][i - 1]][i - 1], mx[v][i - 1]);
  }
  for (auto id : g[v]) {
    int to = id.first, len = id.second;
    if (to != p) {
      deep[to] = deep[v] + 1;
      dfs(to, v, len);
    }
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = l; i >= 0; i--) {
    if (!upper(up[a][i], b)) {
      a = up[a][i];
    }
  }
  return up[a][0];
}
int fun(int v, int depth) {
  if (deep[v] == depth) {
    return 0;
  } else {
    for (int i = 0; i <= l; i++) {
      if (deep[v] - (1 << i) < depth) {
        return max(mx[v][i - 1], fun(up[v][i - 1], depth));
        break;
      }
    }
  }
}
void solve() {
  int n, m;
  cin >> n >> m;
  while ((1 << l) <= n) l++;
  for (int i = 0; i <= n; i++) {
    parent[i] = i;
    up[i].resize(l + 1);
    mx[i].resize(l + 1);
  }
  vector<pair<int, pair<int, int> > > d;
  int e[m], r[m], w[m];
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    e[i] = a;
    r[i] = b;
    w[i] = c;
    d.push_back({c, {a, b}});
  }
  map<pair<int, int>, bool> mp;
  sort(d.begin(), d.end());
  long long ost = 0;
  for (int i = 0; i < d.size(); i++) {
    int val = d[i].first;
    int a = d[i].second.first;
    int b = d[i].second.second;
    a = find_parent(a);
    b = find_parent(b);
    if (a != b) {
      union_set(a, b);
      ost += val;
      mp[d[i].second] = true;
      g[d[i].second.first].push_back({d[i].second.second, val});
      g[d[i].second.second].push_back({d[i].second.first, val});
    }
  }
  dfs(1, 1, 0);
  for (int i = 0; i < m; i++) {
    if (mp[{e[i], r[i]}]) {
      cout << ost << "\n";
    } else {
      int lc = lca(e[i], r[i]);
      int val = max(fun(e[i], deep[lc]), fun(r[i], deep[lc]));
      cout << w[i] - val + ost << "\n";
    }
  }
}
int main() {
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
  return 0;
}
