import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	} main {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int w w n n pos; pos String string; string String[] strings; strings w = sc.nextInt() w sc.nextInt() sc.nextInt sc n = sc.nextInt() n sc.nextInt() sc.nextInt sc int[] endPos = new int[w]; endPos new int[w] w int[] na = new int[n]; na new int[n] n int[] nb = new int[n]; nb new int[n] n for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		} {
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		} string = sc.next() string sc.next() sc.next sc strings = string.split(",") strings string.split(",") string.split string "," na[i] = Integer.parseInt(strings[0]) na[i] na i Integer.parseInt(strings[0]) Integer.parseInt Integer strings[0] strings 0 nb[i] = Integer.parseInt(strings[1]) nb[i] nb i Integer.parseInt(strings[1]) Integer.parseInt Integer strings[1] strings 1 for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		} int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		} {
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		} pos = i + 1 pos i + 1 i 1 for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			} {
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			} if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j]; pos == na[j] pos na[j] na j pos = nb[j] pos nb[j] nb j if(pos == nb[j]) pos = na[j]; pos == nb[j] pos nb[j] nb j pos = na[j] pos na[j] na j endPos[pos - 1] = i + 1 endPos[pos - 1] endPos pos - 1 pos 1 i + 1 i 1 for(int value: endPos){
			System.out.println(value);
		} int value endPos {
			System.out.println(value);
		} {
			System.out.println(value);
		} System.out.println(value) System.out.println System.out System System.out value String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	}
} Main
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w, n, pos;
		String string;
		String[] strings;

		w = sc.nextInt();
		n = sc.nextInt();
		int[] endPos = new int[w];
		int[] na = new int[n];
		int[] nb = new int[n];
		for(int i = 0; i < n; i++){
			string = sc.next();
			strings = string.split(",");
			na[i] = Integer.parseInt(strings[0]);
			nb[i] = Integer.parseInt(strings[1]);
		}

		for(int i = 0; i < w; i++){
			pos = i + 1;
			for(int j = 0; j < n; j++){
				if(pos == na[j]) pos = nb[j];
				else if(pos == nb[j]) pos = na[j];
			}
			endPos[pos - 1] = i + 1;
		}

		for(int value: endPos){
			System.out.println(value);
		}
	}
}