Rosetta Problems

Unionfind with Potential (Non-Commutative Group)

https://judge.yosupo.jp/problem/unionfind_with_potential_non_commutative_group