import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

} Main private int lots[][]; lots public static void main(String[] args) {
		new Main().run();
	} main {
		new Main().run();
	} new Main().run() new Main().run new Main() String[] args args private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	} run {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int w = scan.nextInt(); w scan.nextInt() scan.nextInt scan int n = scan.nextInt(); n scan.nextInt() scan.nextInt scan lots = new int[n+1][w] lots new int[n+1][w] n+1 n 1 w for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		} int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
			lots[0][j] = j+1;
		} {
			lots[0][j] = j+1;
		} lots[0][j] = j+1 lots[0][j] lots[0] lots 0 j j+1 j 1 for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		} int i = 1; int i = 1; i 1 i < n + 1 i n + 1 n 1 i++ i++ i {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		} {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		} String num = scan.next(); num scan.next() scan.next scan int a = num.indexOf(","); a num.indexOf(",") num.indexOf num "," int p = Integer.parseInt(num.substring(0, a))-1; p Integer.parseInt(num.substring(0, a))-1 Integer.parseInt(num.substring(0, a)) Integer.parseInt Integer num.substring(0, a) num.substring num 0 a 1 int q = Integer.parseInt(num.substring(a+1, num.length()))-1; q Integer.parseInt(num.substring(a+1, num.length()))-1 Integer.parseInt(num.substring(a+1, num.length())) Integer.parseInt Integer num.substring(a+1, num.length()) num.substring num a+1 a 1 num.length() num.length num 1 for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			} int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			} {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			} if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				} j != p && j != q j != p j p j != q j q {
					lots[i][j] = lots[i - 1][j];
				} lots[i][j] = lots[i - 1][j] lots[i][j] lots[i] lots i j lots[i - 1][j] lots[i - 1] lots i - 1 i 1 j {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				} lots[i][p] = lots[i - 1][q] lots[i][p] lots[i] lots i p lots[i - 1][q] lots[i - 1] lots i - 1 i 1 q lots[i][q] = lots[i - 1][p] lots[i][q] lots[i] lots i q lots[i - 1][p] lots[i - 1] lots i - 1 i 1 p for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		} int j = 0; int j = 0; j 0 j < w j w j++ j++ j {
			System.out.println(lots[n][j]);
		} {
			System.out.println(lots[n][j]);
		} System.out.println(lots[n][j]) System.out.println System.out System System.out lots[n][j] lots[n] lots n j private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	} debug {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	} for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		} int i = 0; int i = 0; i 0 i < n+1 i n+1 n 1 i++ i++ i {
			System.out.println(Arrays.toString(lots[i]));
		} {
			System.out.println(Arrays.toString(lots[i]));
		} System.out.println(Arrays.toString(lots[i])) System.out.println System.out System System.out Arrays.toString(lots[i]) Arrays.toString Arrays lots[i] lots i System.out.println() System.out.println System.out System System.out int n n public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

} public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	private int lots[][];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int n = scan.nextInt();
		lots = new int[n+1][w];
		
		for (int j = 0; j < w; j++) {
			lots[0][j] = j+1;
		}
		
		for (int i = 1; i < n + 1; i++) {
			String num = scan.next();
			int a = num.indexOf(",");
			int p = Integer.parseInt(num.substring(0, a))-1;
			int q = Integer.parseInt(num.substring(a+1, num.length()))-1;
			
			for (int j = 0; j < w; j++) {
				if (j != p && j != q) {
					lots[i][j] = lots[i - 1][j];
				}else {
					lots[i][p] = lots[i - 1][q];
					lots[i][q] = lots[i - 1][p];
				}
			}
			//debug(n);
		}
		
		for (int j = 0; j < w; j++) {
			System.out.println(lots[n][j]);
		}
	}
	
	private void debug(int n) {
		for (int i = 0; i < n+1; i++) {
			System.out.println(Arrays.toString(lots[i]));
		}
		System.out.println();
	}

}