you give weight tree undirecte connect graph cycle loop multiple edge n vertex the edge u_j v_j weight w_j also vertex value a_i assign itlet path start vertex u end vertex v edge appear twice regardless direction 2path vertex appear 2path multiple time start end verticesFor 2path p profit textprp sumlimits_v textdistinct vertex pa_v sumlimits_e textdistinct edges pk_e cdot w_e k_e number time edge e appear p that vertex count edge count number time appear pyou answer m query each query pair vertex qu qv for query find 2path p qu qv maximal profit textprp