#include using namespace std; using lint = long long int; using P = pair; using PL = pair; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() constexpr int MOD = 1000000007; constexpr lint B1 = 1532834020; constexpr lint M1 = 2147482409; constexpr lint B2 = 1388622299; constexpr lint M2 = 2147478017; constexpr int INF = 2147483647; void yes(bool expr) {cout << (expr ? "YES" : "NO") << "\n";} templatevoid chmax(T &a, const T &b) { if (avoid chmin(T &a, const T &b) { if (b using namespace atcoder; struct Edge{ int s, t, d; }; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); lint n, m; cin >> n >> m; vector e(m); REP(i, m) { cin >> e[i].s >> e[i].t >> e[i].d; e[i].s--; e[i].t--; } sort(ALL(e), [](auto const &a, auto const &b) { return a.d > b.d; }); dsu uf(n); mcf_graph g(n); REP(i, m) { uf.merge(e[i].s, e[i].t); g.add_edge(e[i].s, e[i].t, 1, 1); g.add_edge(e[i].t, e[i].s, 1, 1); if(uf.same(0, n-1)) { cout << e[i].d << " " << g.flow(0, n-1, 1).second << endl; break; } } }