/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	
	 public static int n = 7;

		public static int[][] edges = {
		    {0, 1},
		    {1, 2},
		    {2, 3},
		    {4, 5},
		    {5, 6}
		}; 
		
		public static int[] parent = {0, 1, 2, 3, 4, 5, 6};

	public static int find(int a){
		if(parent[a] == a){
			return a;
		}else{
			return find(parent[a]);
		}
	}
	
	public static void union(int a, int b){
		
		int root1 = find(a);
		int root2 = find(b);
		
		if(root1 == root2){
			
		}else{
			parent[root1] = root2; 
		}
	}
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		
		union(3, 5);
		
		for(int i : parent){
			System.out.print(i + " ");
		}
		
	}
}