#include #include #include #include using namespace std; using i32 = int32_t; using i64 = int64_t; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector>> E; int main(){ cin >> N; rep(i,N*(N-1)/2){ int a,b; cin >> a >> b; a--; b--; string C; cin >> C; reverse(C.begin(),C.end()); C.resize(100,'0'); reverse(C.begin(),C.end()); E.push_back({C,{a,b}}); } sort(E.begin(),E.end()); atcoder::dsu G(N); for(auto& e : E){ G.merge(e.second.first,e.second.second); if(G.size(0) < N) continue; auto c = e.first; reverse(c.begin(),c.end()); while(c.back() == '0') c.pop_back(); reverse(c.begin(),c.end()); cout << c << endl; break; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;