{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eLet’s call a weighted connected undirected graph of $n$ vertices and m edges KD-Graph, if the \u003cbr\u003efollowing conditions fulfill:\u003cbr\u003e\u003cbr\u003e* $n$ vertices are strictly divided into $K$ groups, each group contains at least one vertice\u003cbr\u003e\u003cbr\u003e* if vertices $p$ and $q$ ( $p$ ≠ $q$ ) are in the same group, there must be at least one path between $p$ and $q$ meet the max value in this path is less than or equal to $D$.\u003cbr\u003e\u003cbr\u003e* if vertices $p$ and $q$ ( $p$ ≠ $q$ ) are in different groups, there can’t be any path between $p$ and $q$ meet the max value in this path is less than or equal to $D$.\u003cbr\u003e\u003cbr\u003eYou are given a weighted connected undirected graph $G$ of $n$ vertices and $m$ edges and an integer $K$.\u003cbr\u003e\u003cbr\u003eYour task is find the minimum non-negative $D$ which can make there is a way to divide the $n$ vertices into $K$ groups makes $G$ satisfy the definition of KD-Graph.Or $-1$ if there is no such $D$ exist.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer $T$ (1≤ $T$ ≤5) representing the number of test cases.\u003cbr\u003eFor each test case , there are three integers $n,m,k(2≤n≤100000,1≤m≤500000,1≤k≤n)$ in the first line.\u003cbr\u003eEach of the next $m$ lines contains three integers $u, v$ and $c$ $(1≤v,u≤n,v≠u,1≤c≤10^9)$ meaning that there is an edge between vertices $u$ and $v$ with weight $c$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case print a single integer in a new line."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\r\n3 2 2\r\n1 2 3\r\n2 3 5\r\n3 2 2\r\n1 2 3\r\n2 3 3\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\r\n-1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}