link is the owner of a railway company. The railway company currently operates nnn stations and mmm railway lines.
The railway network consists of n−1n-1n−1 bidirectional railways, and any two stations can be reached from each other through the railway network. The railways in the network can be represented by n−1n-1n−1 triplets (ui,vi,ci)(u_i, v_i, c_i)(ui,vi,ci), where uiu_iui and viv_ivi are the starting and ending stations of the railway, and cic_ici is the daily maintenance cost for that railway.
The operated transport lines of the company can be represented by mmm quadruplets (ai,bi,xi,yi)(a_i, b_i, x_i, y_i)(ai,bi,xi,yi). Here, aia_iai and bib_ibi are the starting and ending stations of the line, xix_ixi represents the daily revenue generated by the line, and yiy_iyi represents the additional expenses incurred by operating this line daily.
The company is currently undergoing a reform: abandoning some underperforming lines and stopping maintenance on certain railways to improve the company's profitability.
link wants to know, in the optimal state, what is the maximum daily revenue the company can achieve after the reform?