import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") # inputna n,m,X = list(map(int, input().split())) M = 10**9+7 xyz = [list(map(int, input().split())) for _ in range(m)] for i in range(m): xyz[i] = (xyz[i][0]-1, xyz[i][1]-1, xyz[i][2]) xyz.sort(key=lambda x: x[2]) class UnionFindTree: def __init__(self, n): self.n = n self.parent = list(range(n)) self.size = [1] * n def root(self, i): inter = set() while self.parent[i]!=i: inter.add(i) i = self.parent[i] r = i for i in inter: self.parent[i] = r return r def connect(self, i, j): ri = self.root(i) rj = self.root(j) if ri==rj: return if self.size[ri]