#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
struct Node {
  int u, v, w;
  int id;
  bool operator<(const Node &o) const { return w < o.w; }
} node[N];
struct Edge {
  int to, next, w;
} edge[N << 1];
int idx, head[N];
void addedge(int u, int v, int w) {
  ++idx;
  edge[idx].to = v;
  edge[idx].next = head[u];
  edge[idx].w = w;
  head[u] = idx;
}
int dep[N];
int par[N][23];
int dis[N][23];
void dfs(int u, int f, int d) {
  dep[u] = d;
  for (int k = head[u]; k; k = edge[k].next) {
    int v = edge[k].to;
    if (v == f) continue;
    par[v][0] = u;
    dis[v][0] = edge[k].w;
    dfs(v, u, d + 1);
  }
}
int kthA(int u, int k) {
  for (int i = 21; i >= 0; i--) {
    if (k >= (1 << i)) {
      k -= (1 << i);
      u = par[u][i];
    }
  }
  return u;
}
int kthD(int u, int k) {
  int ret = 0;
  for (int i = 21; i >= 0; i--) {
    if (k >= (1 << i)) {
      k -= (1 << i);
      ret = max(ret, dis[u][i]);
      u = par[u][i];
    }
  }
  return ret;
}
void calc(int n) {
  for (int i = 1; i <= 21; i++) {
    int k = 1 << (i - 1);
    for (int j = 1; j <= n; j++) {
      par[j][i] = par[par[j][i - 1]][i - 1];
      dis[j][i] = max(dis[j][i - 1], dis[par[j][i - 1]][i - 1]);
    }
  }
}
int get(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  int ret = kthD(u, dep[u] - dep[v]);
  u = kthA(u, dep[u] - dep[v]);
  if (u == v) return ret;
  for (int i = 21; i >= 0; i--) {
    if (par[u][i] == par[v][i]) continue;
    ret = max(ret, dis[u][i]);
    ret = max(ret, dis[v][i]);
    u = par[u][i];
    v = par[v][i];
  }
  ret = max(ret, dis[u][0]);
  ret = max(ret, dis[v][0]);
  return ret;
}
int fa[N];
int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
bool mark[N];
long long ret[N];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  while (cin >> n >> m) {
    for (int i = 1; i <= m; i++) {
      cin >> node[i].u >> node[i].v >> node[i].w;
      node[i].id = i;
      mark[i] = false;
    }
    sort(node + 1, node + 1 + m);
    long long sum = 0;
    for (int i = 1; i <= n; i++) fa[i] = i;
    idx = 1;
    memset(head, 0, sizeof head);
    for (int i = 1; i <= m; i++) {
      int u = node[i].u;
      int v = node[i].v;
      int w = node[i].w;
      int id = node[i].id;
      int fu = find(u);
      int fv = find(v);
      if (fu == fv) continue;
      fa[fu] = fv;
      sum += w;
      mark[id] = true;
      addedge(u, v, w);
      addedge(v, u, w);
    }
    dfs(1, -1, 1);
    calc(n);
    for (int i = 1; i <= m; i++) {
      int id = node[i].id;
      int u = node[i].u;
      int v = node[i].v;
      int w = node[i].w;
      if (mark[id])
        ret[id] = sum;
      else {
        int mx = get(u, v);
        ret[id] = sum + w - mx;
      }
    }
    for (int i = 1; i <= m; i++) cout << ret[i] << endl;
  }
  return 0;
}
