import java.util.*;

class Pair {
	public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
	public int f, s;
}

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	}
} import java.util.*; util.* java class Pair {
	public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
	public int f, s;
} Pair public int f f s; s public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	} Pair {
		this.f = f;
		this.s = s;
	} this.f = f this.f this this.f f this.s = s this.s this this.s s int f f int s s class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	} main {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int w = scanner.nextInt(); w scanner.nextInt() scanner.nextInt scanner int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner Pair[] pairs = new Pair[n]; pairs new Pair[n] n for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		} {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		} String[] s = scanner.next().split(","); s scanner.next().split(",") scanner.next().split scanner.next() scanner.next scanner "," pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1) pairs[i] pairs i new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1) int[] result = new int[w]; result new int[w] w for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		} int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		} {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		} int finger = i; finger i for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			} {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			} if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f; finger == pairs[j].f finger pairs[j].f pairs[j] pairs j pairs[j].f finger = pairs[j].s finger pairs[j].s pairs[j] pairs j pairs[j].s if (finger == pairs[j].s) finger = pairs[j].f; finger == pairs[j].s finger pairs[j].s pairs[j] pairs j pairs[j].s finger = pairs[j].f finger pairs[j].f pairs[j] pairs j pairs[j].f result[finger] = i + 1 result[finger] result finger i + 1 i 1 for (int i = 0; i < w; i++) System.out.println(result[i]); int i = 0; int i = 0; i 0 i < w i w i++ i++ i System.out.println(result[i]); System.out.println(result[i]) System.out.println System.out System System.out result[i] result i String[] args args
import java.util.*;

class Pair {
	public Pair(int f, int s) {
		this.f = f;
		this.s = s;
	}
	public int f, s;
}

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int w = scanner.nextInt();
		int n = scanner.nextInt();
		Pair[] pairs = new Pair[n];
		for (int i = 0; i < n; i++) {
			String[] s = scanner.next().split(",");
			pairs[i] = new Pair(Integer.parseInt(s[0]) - 1, Integer.parseInt(s[1]) - 1);
		}
		int[] result = new int[w];
		for (int i = 0; i < w; i++) {
			int finger = i;
			for (int j = 0; j < n; j++) {
				if (finger == pairs[j].f) finger = pairs[j].s;
				else if (finger == pairs[j].s) finger = pairs[j].f;
			}
			result[finger] = i + 1;
		}
		for (int i = 0; i < w; i++) System.out.println(result[i]);
	}
}