Shorten long line
Implement (inefficient) union-find