#include <bits/stdc++.h>
using namespace std;
inline int getint() {
  char c;
  for (c = getchar(); c < '0' || c > '9'; c = getchar())
    ;
  int t = c - 48;
  for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) t = t * 10 + c - 48;
  return t;
}
inline void putint(long long n) {
  char a[25];
  int size = 0;
  if (n == 0) putchar('0');
  while (n) {
    a[size++] = n % 10 + 48;
    n /= 10;
  }
  for (int i = size - 1; i >= 0; i--) putchar(a[i]);
  putchar('\n');
}
struct node {
  int x, y, d, id;
} edge[300005];
int f[300005][25], g[300005][25], n, m, tin[300005], tout[300005], cnt,
    p[300005];
long long ans[300005];
vector<int> a[300005], cost[300005];
bool vis[300005];
inline bool cmp(const node& ta, const node& tb) { return ta.d < tb.d; }
inline int getfather(int k) { return k == p[k] ? k : p[k] = getfather(p[k]); }
inline void dfs(int k, int fa, int len) {
  tin[k] = ++cnt, f[k][0] = fa, g[k][0] = len;
  for (int i = 1; i < 20; i++) {
    int tmp = f[k][i - 1];
    f[k][i] = f[tmp][i - 1];
    g[k][i] = max(g[k][i - 1], g[tmp][i - 1]);
  }
  for (int i = 0; i < (int)a[k].size(); i++)
    if (fa != a[k][i]) dfs(a[k][i], k, cost[k][i]);
  tout[k] = ++cnt;
}
inline bool ancestor(int x, int y) {
  return (tin[x] <= tin[y] && tout[y] <= tout[x]);
}
int calc(int x, int anc) {
  if (x == anc) return 0;
  int ret = 0;
  for (int i = 19; i >= 0; i--)
    if (!ancestor(f[x][i], anc)) {
      ret = max(ret, g[x][i]);
      x = f[x][i];
    }
  return max(ret, g[x][0]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    edge[i].x = getint();
    edge[i].y = getint();
    edge[i].d = getint();
    edge[i].id = i;
  }
  sort(edge + 1, edge + m + 1, cmp);
  for (int i = 1; i <= n; i++) p[i] = i;
  long long sum = 0;
  for (int k = 0, i = 1; k < n - 1; k++, i++) {
    int fa = getfather(edge[i].x);
    int fb = getfather(edge[i].y);
    if (p[fa] == p[fb]) {
      k--;
      continue;
    }
    p[fa] = p[fb];
    vis[edge[i].id] = true;
    sum += edge[i].d;
    a[edge[i].x].push_back(edge[i].y);
    a[edge[i].y].push_back(edge[i].x);
    cost[edge[i].x].push_back(edge[i].d);
    cost[edge[i].y].push_back(edge[i].d);
  }
  tin[0] = 0;
  tout[0] = (n << 1) + 1;
  dfs(1, 0, 0);
  for (int i = 1; i <= m; i++)
    if (vis[edge[i].id])
      ans[edge[i].id] = sum;
    else {
      int x = edge[i].x, y = edge[i].y, anc;
      if (ancestor(x, y))
        anc = x;
      else if (ancestor(y, x))
        anc = y;
      else {
        anc = x;
        for (int j = 19; j >= 0; j--)
          if (!ancestor(f[anc][j], y)) anc = f[anc][j];
        anc = f[anc][0];
      }
      int mx = max(calc(x, anc), calc(y, anc));
      ans[edge[i].id] = sum - mx + edge[i].d;
    }
  for (int i = 1; i <= m; i++) putint(ans[i]);
  return 0;
}
