Concise union-find python
```\ndef maxNumEdgesToRemove(self, n: int, e: List[List[int]]) -> int:\n\tdef union(UF, u, v):            \n\t\tUF[find(UF, v)] = find(UF, u)\n\tdef find(UF, u)
```\ndef maxNumEdgesToRemove(self, n: int, e: List[List[int]]) -> int:\n\tdef union(UF, u, v):            \n\t\tUF[find(UF, v)] = find(UF, u)\n\tdef find(UF, u):\n\t\tif UF[u] != u: UF[u] = find(UF, UF[u])\n\t\treturn UF[u]         \n\tdef check(UF, t):            \n\t\tUF = UF.copy()\n\t\tfor tp, u, v in e:\n\t\t\tif tp == t: \n\t\t\t\tif find(UF, u) == find(UF, v): self.ans += 1\n\t\t\t\telse: union(UF, u, v)\n\t\treturn len(set(find(UF, u) for u in UF)) == 1, UF\n\n\tself.ans, UF = 0, {u: u for u in range(1, n+1)}                \n\tUF = check(UF, 3)[1]\n\tif not check(UF, 1)[0] or not check(UF, 2)[0]: return -1        \n\treturn self.ans
[]