import java.util.Scanner;


public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} import java.util.Scanner; Scanner java.util public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} Main Scanner sc = new Scanner(System.in); sc new Scanner(System.in) void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	} run {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	} int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[][] h = new int [n][2]; h new int [n][2] n 2 String[] s; s int[] ans = new int [w]; ans new int [w] w for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		} {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		} s = sc.next().split(",") s sc.next().split(",") sc.next().split sc.next() sc.next sc "," h[i][0] = Integer.parseInt(s[0]) h[i][0] h[i] h i 0 Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 h[i][1] = Integer.parseInt(s[1]) h[i][1] h[i] h i 1 Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		} int i=1; int i=1; i 1 i<=w i w i++ i++ i {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		} {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		} int state = i; state i for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			} int j=0; int j=0; j 0 j<n j n j++ j++ j {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			} {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			} if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0]; h[j][0] == state h[j][0] h[j] h j 0 state state = h[j][1] state h[j][1] h[j] h j 1 if ( h[j][1] == state )
					state = h[j][0]; h[j][1] == state h[j][1] h[j] h j 1 state state = h[j][0] state h[j][0] h[j] h j 0 ans[state-1] = i ans[state-1] ans state-1 state 1 i for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		} int i=0; int i=0; i 0 i<w i w i++ i++ i {
			System.out.println(ans[i]);
		} {
			System.out.println(ans[i]);
		} System.out.println(ans[i]) System.out.println System.out System System.out ans[i] ans i public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
} Main
import java.util.Scanner;


public class Main {
	
	Scanner sc = new Scanner(System.in);
	
	void run() {
		
		int w = sc.nextInt();
		int n = sc.nextInt();
		
		int[][] h = new int [n][2];
		
		String[] s;
		int[] ans = new int [w];
		
		for (int i=0;i<n;i++) {
			s = sc.next().split(",");
			
			h[i][0] = Integer.parseInt(s[0]);
			h[i][1] = Integer.parseInt(s[1]);
			
		}
		
		for (int i=1;i<=w;i++) {
			
			int state = i;
			
			for (int j=0;j<n;j++) {
				
				if ( h[j][0] == state )
					state = h[j][1];
				else if ( h[j][1] == state )
					state = h[j][0];	
				
				
			}
			ans[state-1] = i;
		}
		for (int i=0;i<w;i++) {
			System.out.println(ans[i]);
		}
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}