func (set *DisjointSetLL) Union(a, b int) {
	region1 := set.regions[set.Find(a)]
	region2 := set.regions[set.Find(b)]
	if region1.id == region2.id {
		return
	}
	set.totalComponents--
	if region1.rank < region2.rank {
		region2.head, region1.last.next = region1.head, region2.head
		region2.last.next = region2.head
		region2.size += region1.size
		region1.parent = region2
	} else {
		region1.head, region2.last.next = region2.head, region1.head
		region1.last.next = region1.head
		region1.size += region2.size
		region2.parent = region1
		if region1.rank == region2.rank {
			region1.rank++
		}
	}
}
/*
Merge the regions that a and b belong to
package disjointset
import (
	"fmt"
)
type DisjointSetLLNode struct {
	id   int
	next *DisjointSetLLNode
}
type DisjointSetLLRegion struct {
	id     int
	parent *DisjointSetLLRegion
	head   *DisjointSetLLNode
	last   *DisjointSetLLNode
	size   int
	rank   int
}
type DisjointSetLL struct {
	regions         []*DisjointSetLLRegion
	totalComponents int
}
func NewDisjointSetLL(size int) *DisjointSetLL {
	set := new(DisjointSetLL)
	set.regions = make([]*DisjointSetLLRegion, size, size)
	for i, _ := range set.regions {
		set.regions[i] = new(DisjointSetLLRegion)
		region := set.regions[i]
		region.id = i
		region.parent = region
		region.size = 1
		region.rank = 0
		region.head = new(DisjointSetLLNode)
		region.head.id = i
		region.head.next = region.head
		region.last = region.head
	}
	set.totalComponents = size
	return set
}
func (set *DisjointSetLL) TotalComponents() int {
	return set.totalComponents
}
func (set *DisjointSetLL) TotalElements() int {
	return len(set.regions)
}
func (set *DisjointSetLL) Find(v int) int {
	var findNode func(int) *DisjointSetLLRegion
	findNode = func(v int) *DisjointSetLLRegion {
		if set.regions[v].parent.id != v {
			set.regions[v].parent = findNode(set.regions[v].parent.id)
		}
		return set.regions[v].parent
	}
	return findNode(v).id
}
func (set *DisjointSetLL) Size(v int) int {
	return set.regions[set.Find(v)].size
}