Solve TransitiveClosure.