import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto E = new Tuple!(int, int, long, int)[](M);
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        E[i] = tuple(s[0]-1, s[1]-1, s[2].to!long, i);
    }

    E.sort!"a[2] < b[2]";
    auto uf = new UnionFind(N);
    auto mst_edge = new bool[](M);
    auto safe_edge = new bool[](M);
    long mst_cost = 0;
    auto mst = new Tuple!(int, long, int)[][](N);
    auto mst_depth = new int[](N);
    auto mst_parent = new Tuple!(int, long, int)[](N);

    foreach (e; E) {
        if (uf.find(e[0]) != uf.find(e[1])) {
            uf.unite(e[0], e[1]);
            mst_cost += e[2];
            mst_edge[e[3]] = safe_edge[e[3]] = true;
            mst[e[0]] ~= tuple(e[1], e[2], e[3]);
            mst[e[1]] ~= tuple(e[0], e[2], e[3]);
        }
    }


    void dfs(int n, int p, long c, int ei, int d) {
        mst_parent[n] = tuple(p, c, ei);
        mst_depth[n] = d;
        foreach (e; mst[n]) {
            if (e[0] == p) continue;
            dfs(e[0], n, e[1], e[2], d+1);
        }
    }

    dfs(0, -1, 0, -1, 0);


    void solve(int u, int v, long c, int ei) {
        if (mst_depth[u] < mst_depth[v]) {
            swap(u, v);
        }
        while (mst_depth[u] > mst_depth[v]) {
            if (mst_parent[u][1] == c) {
                safe_edge[mst_parent[u][2]] = false;
            }
            u = mst_parent[u][0];
        }
        while (u != v) {
            if (mst_parent[u][1] == c) {
                safe_edge[mst_parent[u][2]] = false;
            }
            u = mst_parent[u][0];
            if (mst_parent[v][1] == c) {
                safe_edge[mst_parent[v][2]] = false;
            }
            v = mst_parent[v][0];
        }
    }

    foreach (e; E) {
        if (mst_edge[e[3]]) continue;
        solve(e[0], e[1], e[2], e[3]);
    }

    writeln(safe_edge.sum, " ", E.filter!(e => safe_edge[e[3]]).map!(e => e[2]).sum);
}


class UnionFind {
    int N;
    int[] table;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        table[x] += table[y];
        table[y] = x;
    }
}

