Pak chanek tree call key tree this tree consist n vertex n1 edge the edge tree number 1 n1 edge connect vertex u_i V_i Initially edge key tree weightformally path length k graph sequence v_1 e_1 v_2 e_2 v_3 e_3 ldot v_k e_k v_k1 for v_i vertex e_i edge for e_i connect vertex v_i v_i1 a circuit path start end vertexA path graph say simple path use edge note simple path use vertex oncethe cost simple path weight graph define maximum weight edge traversescount number distinct undirected weighted graph satisfy follow condition the graph N vertex 2n2 edge for pair different vertex x y exist simple circuit go vertex x y graph the weight edge graph integer 1 2n2 inclusive each edge distinct weight the graph form way way assign weight w_i edge key tree satisfie follow condition for pair edge j ij W_iW_j for pair different vertex index x y cost simple path vertex x y key tree equal minimum cost simple circuit go vertex x y graph Note graph allow multiedge allow selfloop print answer modulo 998244353two graph consider distinct exist triple b c exist edge connect vertex b weight c graph