#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=0;i<l;i++)
        {
            if(x&1){
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
            x>>=1;
        }
    }
    if(u == v)
        return ans;
    for(int i=0;i<l;i++)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    if(m == 0)
    {
        return 0;
    }
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=l-1;i>=0;i--)
        {
            if(x&(1<<i))
            {
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
            x>>=1;
        }
    }
    if(u == v)
        return ans;
    for(int i=l-1;i>=0;i--)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    if(m == 0)
    {
        return 0;
    }
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=l-1;i>=0;i--)
        {
            if(x&(1<<i))
            {
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
        }
    }
    if(u == v)
        return ans;
    for(int i=l-1;i>=0;i--)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    if(m == 0)
    {
        return 0;
    }
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
#define M 100001
#define MAX 1000000010
#define mod 1000000007
#define ss second
#define ff first
#define ll long long int
#define pb push_back
#define ld double
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
vector<vector<pair<int,int> > >adj,up;
vector<int>depth;
int l;
ll cost=0;

void dfs(int current,int parent,int h,int w)
{
    depth[current]=h;
    up[current][0].ff = parent;
    up[current][0].ss = w;
    for(int i=1;i<l;i++)
    {
        up[current][i].ff = up[up[current][i-1].ff][i-1].ff;
        up[current][i].ss = max(up[current][i-1].ss,up[up[current][i-1].ff][i-1].ss);
    }
    for(pair<int,int>p:adj[current])
    {
        if(p.ss != parent)
            dfs(p.ss,current,h+1,p.ff);
    }
}

int lca(int u,int v)
{
    int ans = 0;
    if(u == v)
        return 0;
    if(depth[u]<depth[v])
        swap(u,v);
    if(depth[u] != depth[v])
    {
        int x = depth[u]-depth[v];
        for(int i=0;i<l;i++)
        {
            if(x&1){
                ans = max(ans,up[u][i].ss);
                u=up[u][i].ff;
            }
            x>>=1;
        }
    }
    if(u == v)
        return ans;
    for(int i=0;i<l;i++)
    {
        if(up[u][i].ff != up[v][i].ff)
        {
            ans=max(ans,up[u][i].ss);
            ans=max(ans,up[v][i].ss);
            u=up[u][i].ff;
            v=up[v][i].ff;
        }
    }
    ans = max(ans,up[u][0].ss);
    ans = max(ans,up[v][0].ss);
    return ans;
}

void mst(vector<pair<int,int> >adj1[],int n)
{
    bool visited[n+1]={0};
    int cnt=0;
    set<pair<int,pair<int,int> > > s;
    visited[1]=1;
    cnt=1;
    for(pair<int,int>p:adj1[1])
    {
        s.insert({p.ff,{1,p.ss}});
    }
    while(cnt<n)
    {
        auto p = s.begin();
        if(visited[p->ss.ss] && visited[p->ss.ff])
        {
            s.erase(p);
            continue;
        }
        visited[p->ss.ss] = true;
        visited[p->ss.ff] = true;
        adj[p->ss.ff].pb({p->ff,p->ss.ss});
        adj[p->ss.ss].pb({p->ff,p->ss.ff});
        cost+=p->ff;

        for(pair<int,int>p1:adj1[p->ss.ss])
        {
            s.insert({p1.ff,{p->ss.ss,p1.ss}});
        }
        cnt++;
    }
}

struct node{
    int u,v,w;
};

int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    depth.resize(n+1);
    up.resize(n+1);
    l=ceil(log2(n));
    node array[m];
    for(int i=0;i<=n;i++)
    {
        up[i].resize(l);
    }
    vector<pair<int,int> > adj1[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        array[i].u = u;
        array[i].v = v;
        array[i].w = w;
        adj1[u].pb({w,v});
        adj1[v].pb({w,u});
    }
    mst(adj1,n);
    dfs(1,1,0,0);
    for(int i=0;i<m;i++)
    {
        ll x = lca(array[i].u,array[i].v);
        ll a1 = cost-x+array[i].w;
        cout<<a1<<endl;
    }

    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];

        }
    }
    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(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;
}


#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(int i = 0; i < n; i++)if(len(t[i]) == 0)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)) > 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;
    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});
    }
    if(uu != n-1)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 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]));
        }
    }
}

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);

    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!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

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 get_max (int u, int v) {
    if (h[u] > h[v]) {
        return get_max(v, u);
    }
    assert(u != v);
    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 = std::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] = -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;
}


#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 = 29; j>= 0; 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);
    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(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);
    }
    assert(u != v);
    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 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] > 0){
            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 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 get_max (int u, int v) {
    if (h[u] > h[v]) {
        return get_max(v, u);
    }
    assert(u != v);
    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 = std::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] = -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 - get_max(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);

    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);
        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);

    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);
        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);
    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[0];
    for(int i =1 ;i <n; i++)if(id[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 = 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(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;
}