polycarp develop RPG game main character fight monster search treasure dungeon now Polycarp make dungeon character explorethe dungeon consist n room connect m twoway tunnel possible reach room room tunnel the room guard monster number monster ith room a_i tunnel contain gold coin number coin ith tunnel w_i the ith twoway tunnel connect room v_i u_ipolycarp fix number coin tunnel value w_i know try place monster room value a_i know Polycarp wants choose number monster room way follow condition meet number coin tunnel connect room x y equal minimum a_x a_y that tunnel w_i min a_v_i a_u_i number monster dungeon small possible that value a_1 a_2 dot a_n minimum possible help Polycarp choose value a_1 a_2 a_n tell impossible change dungeon plan