build maze using union find