public static void main(String[] args) {

    long start = System.currentTimeMillis();
    int n = StdIn.readInt();
    UF uf = new UF(n);
    while(!StdIn.isEmpty()) {
      int p = StdIn.readInt();
      int q = StdIn.readInt();
      if (!uf.connected(p, q)) {
        uf.union(p, q);
        System.out.println(p + ":" + q);
      }
    }
    long end = System.currentTimeMillis();
    StdOut.println("cost time:" + (end -  start));
  }