inlinevoidyhm_func() { int i, x, y; n = read(), m = read(); for (i = 1; i <= n; ++ i) { a[i] = read(); if (a[i] > a[fa]) fa = i; elseif (a[i] == a[fa] && i < fa) fa = i; } for (i = 1; i < n; ++ i) { x = read(), y = read(); add_edge(x, y), add_edge(y, x); } if (n == 1) return (void)(put(1)); for (i = head[fa]; i; i = nex[i]) { y = ver[i]; if (a[y] > a[son]) son = y; elseif (a[y] == a[son] && y < son) son = y; } //cout << "fa-->" << fa << " son-->" << son << '\n' if (a[fa] - a[son] > m) return (void)(put(fa)); if (a[fa] - a[son] == m) return (void)(put(min(fa, son))); int rest = m - (a[fa] - a[son]); if (fa > son) swap(fa, son); if (rest & 1) return (void)(put(son)); return (void)(put(fa)); }
signedmain() { T = read(); while (T --) { yhm_clear(); yhm_func(); } return0; }