import java.util.Arrays; import java.util.Scanner; import java.util.stream.IntStream; public class Main{ static IntStream REPS(int v){return IntStream.range(0,v);} static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);} static IntStream INS(int n) {return REPS(n).map(i->getInt());} static Scanner s=new Scanner(System.in); static int getInt(){return Integer.parseInt(s.next());} public static void main(String[]$){ int n=getInt(),q=getInt(); UF uf=new UF(n); for(int i=0;igb){ uf.connect(a,b); }else { if(uf.root(a)uf.root(i)+1).forEach(System.out::println); } } class UF{ public int[] uni; public UF(int size){ uni=new int[size]; Arrays.fill(uni,-1); } public int root(int t){ if(uni[t]<0) return t; return uni[t]=root(uni[t]); } public boolean connect(int p,int c){ p=root(p); c=root(c); if(isConnected(p,c)) return false; if(uni[p]>uni[c]){ final int buf=c; c=p; p=buf; } uni[p]+=uni[c]; uni[c]=p; return true; } public boolean isConnected(int a,int b){ return root(a)==root(b); } public int groupSize(int t){ return -uni[root(t)]; } }