#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int isgood[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = INT_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j >=0; j--){
        if( h[b] - h[a]){
            ma(re, heavy[b][j]);
            b = p[b][j];
        }
    }
    if(a == b)return re;

    for(int j = 29; j>= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];

        }
    }
    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        isgood[e[i].id] = 1;
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        if(isgood[e[i].id]){
            re[e[i].id] = yy;
        }
        else{
            re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
        }
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    int pp = h[b] - h[a];
    for(int j = 29; j>= 0; j--){
        if((pp) &(1 << j)){
            ma(re, heavy[b][j]);
            pp -= (1 << j);
            if(pp)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace
#define int long long

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
//int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int isgood[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = INT_MIN;
    if(h[a] > h[b])swap(a,b);
    int pp = h[b] - h[a];
    for(int j = 0; j <30 && pp; j++){
        if(  pp &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            pp -= (1<< j);
        }
    }
    if(a == b)return re;

    for(int j = 29; j>= 1; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];

        }
    }
    if(a != b){
        ma(re, heavy[a][0]);
        ma(re, heavy[b][0]);
    }
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int32_t main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%lld %lld", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%lld %lld %lld", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        isgood[e[i].id] = 1;
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        if(isgood[e[i].id]){
            re[e[i].id] = yy;
        }
        else{
            re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
        }
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int isgood[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = INT_MIN;
    if(h[a] > h[b])swap(a,b);
    int pp = h[b] - h[a];
    for(int j = 0; j <30 && pp; j++){
        if(  pp &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            pp -= (1<< j);
        }
    }
    if(a == b)return re;

    for(int j = 29; j>= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];

        }
    }
    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        isgood[e[i].id] = 1;
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        if(isgood[e[i].id]){
            re[e[i].id] = yy;
        }
        else{
            re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
        }
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int isgood[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = INT_MIN;
    if(h[a] > h[b])swap(a,b);
    int pp = h[b] - h[a];
    for(int j = 0; j <30 && pp; j++){
        if(  pp &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            pp -= (1<< j);
            if(pp<0)printf("!!!!!!!!!!!!");
        }
    }
    if(a == b)return re;

    for(int j = 29; j>= 1; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];

        }
    }
    if(a != b){
        ma(re, heavy[a][0]);
        ma(re, heavy[b][0]);
    }
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = -1, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            if(p[i][j-1] != -1) {
                p[i][j] = p[p[i][j - 1]][j - 1];
                ma(heavy[i][j], max(heavy[i][j - 1], heavy[p[i][j - 1]][j - 1]));
            }
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        isgood[e[i].id] = 1;
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        if(isgood[e[i].id]){
            re[e[i].id] = yy;
        }
        else{
            re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
        }
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <ctime>
#include <climits>
#include <stack>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran() {
	return (rand() << 15) | rand();
}

int const maxn = 200005;
int n, m;
struct edge {
	int a, b, w, id;
	edge() {}
	edge(int aa, int bb, int ww, int i) {
		id = i;
		a = aa;
		b = bb;
		w = ww;
	}
} e[maxn];
int p[maxn][20];
ll ww[maxn][20];
vector<pair<int, int> > g[maxn];
int h[maxn];
int ids[maxn];
ll re[maxn];
ll res = 0;
int get(int id) {
	if (ids[id] == id)return id;
	return ids[id] = get(ids[id]);
}
void con(int a, int b) {
	a = get(a);
	b = get(b);
	ids[b] = a;
}

void dfs0(int ind, int s = 1) {
	h[ind] = s;
	for (auto &i : g[ind])if (h[i.first] == 0) {
		dfs0(i.first, s + 1);
		p[i.first][0] = ind;
		ww[i.first][0] = i.second;
	}
}

ll getfat(int a, int b) {
	ll po = 0;
	if (a == b)throw(1);
	if (h[a] > h[b])swap(a, b);
	while (h[a] != h[b]) {
		for (int j = 19; j >= 0; j--) {
			int pre = p[b][j];
			if (pre != -1) {
				if (h[pre] >= h[a]) {
					ma(po, ww[b][j]);
					b = pre;
				}
			}
		}
	}
	while (h[a] != h[b]);
	if (a == b)return po;
	for (int j = 19; j >= 0; j--) {
		int pa = p[a][j];
		int pbb = p[b][j];
		if (pa != -1 && pbb != -1) {
			if (pa != pbb) {
				ma(po, ww[a][j]);
				ma(po, ww[b][j]);
				a = pa;
				b = pbb;
			}
		}
	}
	if (a == b)return po;
	ma(po, ww[a][0]);
	ma(po, ww[b][0]);
	return po;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("chocolate.in", "r", stdin);
	//freopen("chocolate.out", "w", stdout);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		int a, b, w;
		scanf("%d %d %d", &a, &b, &w);
		a--;
		b--;
		e[i] = edge(a, b, w, i);
	}

	sort(e, e + m, [&](edge &l, edge &r) {return l.w < r.w; });
	for (int i = 0; i < n; i++)ids[i] = i;
	for (int i = 0; i < m; i++) {
		if (get(e[i].a) == get(e[i].b))continue;
		con(e[i].a, e[i].b);
		g[e[i].a].eb(e[i].b, e[i].w);
		g[e[i].b].eb(e[i].a, e[i].w);
		res += e[i].w;
	}
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < 20; j++) {
			p[i][j] = -1;
			ww[i][j] = 0;
		}
		h[i] = 0;
	}
	dfs0(0);
	for (int j = 1; j < 20; j++) {
		for (int i = 0; i < n; i++) {
			int pre = p[i][j - 1];
			if (pre != -1) {
				p[i][j] = p[pre][j - 1];
				ma(ww[i][j], max(ww[i][j - 1], ww[pre][j - 1]));
			}
			else {
				ma(ww[i][j], ww[i][j - 1]);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		re[e[i].id] = res - getfat(e[i].a, e[i].b) + e[i].w;
	}
	for (int i = 0; i < m; i++)printf("%lld\n", re[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);

    for(int j = 29; j>= 0; j--){
        if((h[b] - h[a]) &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] < h[a])printf("%d %d %d %d", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);

    for(int j = 29; j>= 0; j--){
        if((h[b] - h[a]) &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            while(h[b] < h[a]);
        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if(((h[b] - h[a])&(1 << j)) > 0){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 1; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(e[i].a == e[i].b)throw(1);
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].pb({e[i].b, e[i].w});
        t[e[i].b].pb({e[i].a, e[i].w});
    }
    for(auto &i: h)i = 0;
    int last = id[get(0)];
    for(int i =1 ;i <n; i++)if(id[get(i)] != last)throw(1);
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if((h[b] - h[a]) &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    for(auto &i: h)i = 0;
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if(((h[b] - h[a])&(1 << j)) > 0){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 1; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(e[i].a == e[i].b)throw(1);
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    for(auto &i: h)i = 0;
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if((h[b] - h[a]) &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <ctime>
#include <climits>
#include <stack>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran() {
	return (rand() << 15) | rand();
}

int const maxn = 200005;
int n, m;
struct edge {
	int a, b, w, id;
	edge() {}
	edge(int aa, int bb, int ww, int i) {
		id = i;
		a = aa;
		b = bb;
		w = ww;
	}
} e[maxn];
int p[maxn][20];
ll ww[maxn][20];
vector<pair<int, int> > g[maxn];
int h[maxn];
int ids[maxn];
ll re[maxn];
ll res = 0;
int get(int id) {
	if (ids[id] == id)return id;
	return ids[id] = get(ids[id]);
}
void con(int a, int b) {
	a = get(a);
	b = get(b);
	ids[b] = a;
}

void dfs0(int ind, int s = 1) {
	h[ind] = s;
	for (auto &i : g[ind])if (h[i.first] == 0) {
		dfs0(i.first, s + 1);
		p[i.first][0] = ind;
		ww[i.first][0] = i.second;
	}
}

ll getfat(int a, int b) {
	ll po = 0;
	if (a == b)throw(1);
	if (h[a] > h[b])swap(a, b);
	while (h[a] != h[b]) {
		for (int j = 19; j >= 0; j--) {
			int pre = p[b][j];
			if (pre != -1) {
				if (h[pre] >= h[a]) {
					ma(po, ww[b][j]);
					b = pre;
				}
			}
		}
	}
	while (h[a] != h[b]);
	if (a == b)return po;
	for (int j = 19; j >= 0; j--) {
		int pa = p[a][j];
		int pbb = p[b][j];
		if (pa != -1 && pbb != -1) {
			if (pa != pbb) {
				ma(po, ww[a][j]);
				ma(po, ww[b][j]);
				a = pa;
				b = pbb;
			}
		}
	}
	if (a == b)return po;
	ma(po, ww[a][0]);
	ma(po, ww[b][0]);
	return po;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("chocolate.in", "r", stdin);
	//freopen("chocolate.out", "w", stdout);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		int a, b, w;
		scanf("%d %d %d", &a, &b, &w);
		a--;
		b--;
		e[i] = edge(a, b, w, i);
	}

	sort(e, e + m, [&](edge &l, edge &r) {return l.w < r.w; });
	for (int i = 0; i < n; i++)ids[i] = i;
	for (int i = 0; i < m; i++) {
		if (get(e[i].a) == get(e[i].b))continue;
		con(e[i].a, e[i].b);
		g[e[i].a].eb(e[i].b, e[i].w);
		g[e[i].b].eb(e[i].a, e[i].w);
		res += e[i].w;
	}
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < 20; j++) {
			p[i][j] = -1;
			ww[i][j] = 0;
		}
		h[i] = 0;
	}
	dfs0(0);
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < 20; j++) {
			int pre = p[i][j - 1];
			if (pre != -1) {
				p[i][j] = p[pre][j - 1];
				ma(ww[i][j], max(ww[i][j - 1], ww[pre][j - 1]));
			}
			else {
				ma(ww[i][j], ww[i][j - 1]);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		re[e[i].id] = res - getfat(e[i].a, e[i].b) + e[i].w;
	}
	for (int i = 0; i < m; i++)printf("%lld\n", re[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int u, int v){
    if (h[u] > h[v]) {
        return getfat(v, u);
    }
    if(u == v)printf("!!!!!!!");
    ll answ = 0;
    int diff = h[v] - h[u];
    int pow = 0;
    while ((1 << (pow+1)) <= diff) ++pow;

    while (h[v] != h[u]) {
        assert(diff != 0);
        while (pow > 0 && diff < (1 << pow)) --pow;
        answ = max(answ, heavy[v][pow]);
        v = p[v][pow];
        diff -= 1 << pow;
    }
    pow = 0;
    while (u != v) {
        while (pow > 0 && p[u][pow] == p[v][pow]) --pow;
        answ = std::max({answ, heavy[u][pow], heavy[v][pow]});
        u = p[u][pow];
        v = p[v][pow];
    }
    return answ;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    for(int i = 0; i < n; i++)if(len(t[i]) == 0 && n != 1)throw(1);
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int u, int v){
    if (h[u] > h[v]) {
        return getfat(v, u);
    }
    if(u == v)printf("!!!!!!!");
    ll answ = 0;
    int diff = h[v] - h[u];
    int pow = 0;
    while ((1 << (pow+1)) <= diff) ++pow;

    while (h[v] != h[u]) {
        assert(diff != 0);
        while (pow > 0 && diff < (1 << pow)) --pow;
        answ = max(answ, heavy[v][pow]);
        v = p[v][pow];
        diff -= 1 << pow;
    }
    pow = 0;
    while (u != v) {
        while (pow > 0 && p[u][pow] == p[v][pow]) --pow;
        answ = std::max({answ, heavy[u][pow], heavy[v][pow]});
        u = p[u][pow];
        v = p[v][pow];
    }
    return answ;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    for(int i = 0; i < n; i++)if(len(t[i]) == 0 && n != 1)while(1);
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll fat(int a, int b){
    ll res = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if(((h[b] - h[a])&(1 << j)) > 0){
            ma(res, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return res;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(res, heavy[a][j]);
            ma(res, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(res, heavy[a][0]);
    ma(res, heavy[b][0]);
    return res;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 1; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(e[i].a == e[i].b)throw(1);
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].pb({e[i].b, e[i].w});
        t[e[i].b].pb({e[i].a, e[i].w});
    }
    for(auto &i: h)i = 0;
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - fat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <functional>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <cstdlib>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <deque>
#include <random>
#include <ctime>
#include <climits>
#include <stack>
#include <iomanip>
#include <complex>
#include <bitset>
#include <iostream>
#include <cstring>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
	return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
	return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran() {
	return (rand() << 15) | rand();
}

int const maxn = 200005;
int n, m;
struct edge {
	int a, b, w, id;
	edge() {}
	edge(int aa, int bb, int ww, int i) {
		id = i;
		a = aa;
		b = bb;
		w = ww;
	}
} e[maxn];
int p[maxn][20];
ll ww[maxn][20];
vector<pair<int, int> > g[maxn];
int h[maxn];
int ids[maxn];
ll re[maxn];
ll res = 0;
int get(int id) {
	if (ids[id] == id)return id;
	return ids[id] = get(ids[id]);
}
void con(int a, int b) {
	a = get(a);
	b = get(b);
	ids[b] = a;
}

void dfs0(int ind, int s = 1) {
	h[ind] = s;
	for (auto &i : g[ind])if (h[i.first] == 0) {
		dfs0(i.first, s + 1);
		p[i.first][0] = ind;
		ww[i.first][0] = i.second;
	}
}

ll getfat(int a, int b) {
	ll po = 0;
	if (a == b)throw(1);
	if (h[a] > h[b])swap(a, b);
	while (h[a] != h[b]) {
		for (int j = 19; j >= 0; j--) {
			int pre = p[b][j];
			if (pre != -1) {
				if (h[pre] >= h[a]) {
					ma(po, ww[b][j]);
					b = pre;
				}
			}
		}
	}
	if (a == b)return po;
	for (int j = 19; j >= 0; j--) {
		int pa = p[a][j];
		int pbb = p[b][j];
		if (pa != -1 && pbb != -1) {
			if (pa != pbb) {
				ma(po, ww[a][j]);
				ma(po, ww[b][j]);
				a = pa;
				b = pbb;
			}
		}
	}
	if (a == b)return po;
	ma(po, ww[a][0]);
	ma(po, ww[b][0]);
	return po;
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("chocolate.in", "r", stdin);
	//freopen("chocolate.out", "w", stdout);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++) {
		int a, b, w;
		scanf("%d %d %d", &a, &b, &w);
		a--;
		b--;
		e[i] = edge(a, b, w, i);
	}

	sort(e, e + m, [&](edge &l, edge &r) {return l.w < r.w; });
	for (int i = 0; i < n; i++)ids[i] = i;
	for (int i = 0; i < m; i++) {
		if (get(e[i].a) == get(e[i].b))continue;
		con(e[i].a, e[i].b);
		g[e[i].a].eb(e[i].b, e[i].w);
		g[e[i].b].eb(e[i].a, e[i].w);
		res += e[i].w;
	}
	for (int i = 0; i < maxn; i++) {
		for (int j = 0; j < 20; j++) {
			p[i][j] = -1;
			ww[i][j] = 0;
		}
		h[i] = 0;
	}
	dfs0(0);
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < 20; j++) {
			int pre = p[i][j - 1];
			if (pre != -1) {
				p[i][j] = p[pre][j - 1];
				ma(ww[i][j], max(ww[i][j - 1], ww[pre][j - 1]));
			}
			else {
				ma(ww[i][j], ww[i][j - 1]);
			}
		}
	}
	for (int i = 0; i < m; i++) {
		re[e[i].id] = res - getfat(e[i].a, e[i].b) + e[i].w;
	}
	for (int i = 0; i < m; i++)printf("%lld\n", re[i]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    for(int j = 29; j>= 0; j--){
        if(((h[b] - h[a])&(1 << j)) > 0){
            ma(re, heavy[b][j]);
            b = p[b][j];
            if(h[b] - h[a]<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 1; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;int uu = 0;
    set<int> py;
    for(int i = 0; i < m; i++){
        if(e[i].a == e[i].b)throw(1);
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        uu++;
        t[e[i].a].pb({e[i].b, e[i].w});
        t[e[i].b].pb({e[i].a, e[i].w});
        py.insert(e[i].a);
        py.insert(e[i].b);
    }
    if(uu != n-1)throw(1);
    if(len(py) != n)throw(1);
    for(auto &i: h)i = 0;
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = INT_MIN;
    if(h[a] > h[b])swap(a,b);

    for(int j = 0; j< 30; j++){
        if((h[b] - h[a]) &(1 << j)){
            ma(re, heavy[b][j]);
            b = p[b][j];
        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ld = double;

#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define len(a) (int)a.size()
#define pb push_back
#define eb emplace_back
#define em emplace

ld const pi = acos(-1.0);
ld const eps = 0.000000000001;
int const inf = int(1e9 + 7);

ll gcd(ll a, ll b) {
    return b == 0 ? a : gcd(b, a % b);
}
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

template<class T> bool mi(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool ma(T &a, T b) { return a < b ? (a = b, true) : false; }

inline int ran(){
    return (rand() << 15) | rand();
}

struct decartach {
    struct node {
        int x, y, sz;
        node *l, *r;

        node() {
            l = r = nullptr;
            sz = 0;
        }

        node(int what) {
            x = what;
            y = ran();
            l = r = nullptr;
            sz = 1;
        }
    };

    int getsz(node *r) {
        if (!r)return 0;
        return r->sz;
    }

    void upd(node *r) {
        if (!r) {
            return;
        }
        r->sz = 1 + getsz(r->l) + getsz(r->r);
    }

    void split(node *root, node *&l, node *&r, int x) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (root->x <= x) {
            split(root->r, root->r, r, x);
            upd(l);
            l = root;
        } else {
            split(root->l, l, root->l, x);
            upd(r);
            r = root;
        }
    }

    void getfirstk(node *root, node *&l, node *&r, int k) {
        if (!root) {
            l = r = nullptr;
            return;
        }
        if (k == 0) {
            l = nullptr;
            r = root;
            return;
        }
        if (getsz(root->l) >= k) {
            node *p1, *p2;
            getfirstk(root->l, p1, p2, k);
            root->l = p2;
            upd(root);
            l = p1;
            r = root;
        } else {
            node *p1, *p2;
            getfirstk(root->r, p1, p2, k - getsz(root->l) - 1);
            root->r = p1;
            upd(root);
            l = root;
            r = p2;
        }
    }

    void merge(node *&root, node *l, node *r) {
        if (!l) {
            root = r;
            return;
        }
        if (!r) {
            root = l;
            return;
        }
        if (l->y > r->y) {
            merge(l->r, l->r, r);
            upd(l);
            root = l;
        } else {
            merge(r->l, l, r->l);
            upd(r);
            root = r;
        }

    }

    void print(node *r) {
        if (!r)return;
        print(r->l);
        printf("%d ", r->x);
        print(r->r);
    }

};

int n,m;
struct edge{
    int a, b;
    int w;
    int id;
};
edge e[200005];
vector<pair<int,int> > t[200005];
int id[200005];
ll re[200005];
int p[200005][30];
int h[200005];
ll heavy[200005][30];

int get(int ind){
    if(id[ind] == ind)return ind;
    return id[ind] = get(id[ind]);
}

void con(int a,int b){
    a = get(a);
    b = get(b);
    id[b] = a;
}

ll getfat(int a, int b){
    ll re = LLONG_MIN;
    if(h[a] > h[b])swap(a,b);
    int pp = h[b] - h[a];
    for(int j = 29; j>= 0; j--){
        if((pp) &(1 << j)){
            ma(re, heavy[b][j]);
            pp -= (1 << j);
            b = p[b][j];
            if(pp<0)printf("!%d %d %d %d!S", a, b, h[a], h[b]);

        }
    }

    if(a == b)return re;

    for(int j = 29; j >= 0; j--){
        if(p[a][j] != p[b][j]){
            ma(re, heavy[a][j]);
            ma(re, heavy[b][j]);
            a = p[a][j];
            b = p[b][j];
        }
    }

    ma(re, heavy[a][0]);
    ma(re, heavy[b][0]);
    return re;
}

void dfs0(int ind, int s){
    h[ind] = s;
    for(auto &i: t[ind]){
        if(h[i.first] == 0) {
            dfs0(i.first, s + 1);
            p[i.first][0] = ind;
            heavy[i.first][0] = i.second;
        }
    }
}

void prec(){
    for(int i = 0 ;i < 200005; i++)for(int j = 0 ;j <30; j++)p[i][j] = 0, heavy[i][j] = 0;
    dfs0(0, 1);
    for(int i = 0; i<n;i++){
        for(int j = 1; j< 30; j++){
            p[i][j] = p[p[i][j-1]][j-1];
            ma(heavy[i][j], max(heavy[i][j-1], heavy[p[i][j-1]][j-1]));
        }
    }
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("chocolate.in", "r", stdin);
    //freopen("chocolate.out", "w", stdout);
#endif

    scanf("%d %d", &n, &m);
    for(int i = 0; i <n; i++)id[i] = i;
    for(int i= 0; i <m ;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        a--;
        b--;
        e[i].a=a;
        e[i].b=b;
        e[i].w=c;
        e[i].id=i;
    }
    sort(e, e + m, [&](edge &l, edge &r){return l.w < r.w;});
    ll yy = 0;
    for(int i = 0; i < m; i++){
        if(get(e[i].a) == get(e[i].b))continue;
        con(e[i].a, e[i].b);
        yy += e[i].w;
        t[e[i].a].eb(e[i].b, e[i].w);
        t[e[i].b].eb(e[i].a, e[i].w);
    }
    prec();
    for(int i = 0; i <m; i++) {
        re[e[i].id] = yy - getfat(e[i].a, e[i].b) + e[i].w;
    }
    for(int i = 0 ;i < m;i++)printf("%lld\n", re[i]);
    return 0;
}