import java.io.*;class Main{public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];}for(i=0;++i<l;)System.out.println(w[i]);}} import java.io.*; io.* java class Main{public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];}for(i=0;++i<l;)System.out.println(w[i]);}} Main public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];}for(i=0;++i<l;)System.out.println(w[i]);} main {BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];}for(i=0;++i<l;)System.out.println(w[i]);} BufferedReader B=new BufferedReader(new InputStreamReader(System.in)); B new BufferedReader(new InputStreamReader(System.in)) Integer i=0 i 0 o o m m l=1+i.valueOf(B.readLine()) l 1+i.valueOf(B.readLine()) 1 i.valueOf(B.readLine()) i.valueOf i B.readLine() B.readLine B w[]=new Integer[l] w new Integer[l] l n=i.valueOf(B.readLine()); n i.valueOf(B.readLine()) i.valueOf i B.readLine() B.readLine B while(i<l)w[i]=i++; i<l i l w[i]=i++ w[i] w i i++ i for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];} ; n-->0 n-- n 0 w[m]=i w[m]=i w[m] w m i {g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];} {g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];} g=B.readLine().split(",") g B.readLine().split(",") B.readLine().split B.readLine() B.readLine B "," i=w[o=i.valueOf(g[0])] i w[o=i.valueOf(g[0])] w o=i.valueOf(g[0]) o i.valueOf(g[0]) i.valueOf i g[0] g 0 w[o]=w[m=i.valueOf(g[1])] w[o] w o w[m=i.valueOf(g[1])] w m=i.valueOf(g[1]) m i.valueOf(g[1]) i.valueOf i g[1] g 1 for(i=0;++i<l;)System.out.println(w[i]); i=0; i=0 i 0 ++i<l ++i i l System.out.println(w[i]); System.out.println(w[i]) System.out.println System.out System System.out w[i] w i String[]g g
import java.io.*;class Main{public static void main(String[]g)throws Exception{BufferedReader B=new BufferedReader(new InputStreamReader(System.in));Integer i=0,o,m,l=1+i.valueOf(B.readLine()),w[]=new Integer[l],n=i.valueOf(B.readLine());while(i<l)w[i]=i++;for(;n-->0;w[m]=i){g=B.readLine().split(",");i=w[o=i.valueOf(g[0])];w[o]=w[m=i.valueOf(g[1])];}for(i=0;++i<l;)System.out.println(w[i]);}}
