You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: d.go
    path of file: ./repos/codeforces-go/leetcode/weekly/220/d
    
    the code of the file until where you have to start completion: package main

import "sort"

// 在线的话可以用最小生成树+倍增

// github.com/EndlessCheng/codeforces-go
type uf struct {
	fa []int
}

func newUnionFind(n int) uf {
	fa := make([]int, n)
	for i := range 
    
func distanceLimitedPathsExist(n int, es, qs [][]int) (ans []bool) {
	sort.Slice(es, func(i, j int) bool { return es[i][2] < es[j][2] })
	ans = make([]bool, len(qs))
	u := newUnionFind(n)
	for i := range qs {
		qs[i] = append(qs[i], i)
	}
	sort.Slice(qs, func(i, j int) bool { return qs[i][2] < qs[j][2] })
	for _, q := range qs {
		for len(es) > 0 && es[0][2] < q[2] {
			e := es[0]
			es = es[1:]
			u.merge(e[0], e[1])
		}
		ans[q[3]] = u.same(q[0], q[1])
	}
	return
}