ample-code">import atcoder/header
import atcoder/dsu

let n, q = nextInt()
var d = initDSU(n)
for i in 0..&lt;q:
  let t, u, v = nextInt()
  if t == 0:
    d.merge(u, v)
  else:
    if d.same(u, v):
      echo 1
    else:
      echo 0

</div>
        </div>
    </section>
</body>

</html>
