import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	}

	static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	}

} import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStreamReader; InputStreamReader java.io import java.util.ArrayDeque; ArrayDeque java.util import java.util.ArrayList; ArrayList java.util import java.util.Deque; Deque java.util import java.util.List; List java.util public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	}

	static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	}

} Main @SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	} main {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	} BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) int w = Integer.parseInt(br.readLine()); w Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int n = Integer.parseInt(br.readLine()); n Integer.parseInt(br.readLine()) Integer.parseInt Integer br.readLine() br.readLine br int[] ans = new int[w + 1]; ans new int[w + 1] w + 1 w 1 List<points> line = new ArrayList<>(); line new ArrayList<>() for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		} {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		} String[] s_points = br.readLine().split(","); s_points br.readLine().split(",") br.readLine().split br.readLine() br.readLine br "," line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1]))) line.add line new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])) Deque<points> d = new ArrayDeque<>(); d new ArrayDeque<>() for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		} int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		} {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		} int target = i; target i d.addAll(line) d.addAll d line while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			} !(d.isEmpty()) (d.isEmpty()) d.isEmpty d {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			} points p = d.poll(); p d.poll() d.poll d if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				} target == p.point_a target p.point_a p p.point_a {
					target = p.point_b;
				} target = p.point_b target p.point_b p p.point_b if (target == p.point_b) {
					target = p.point_a;
				} target == p.point_b target p.point_b p p.point_b {
					target = p.point_a;
				} target = p.point_a target p.point_a p p.point_a ans[target] = i ans[target] ans target i for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		} int i = 1; int i = 1; i 1 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 String[] args args static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	} points int point_a; point_a int point_b; point_b public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		} points {
			this.point_a = a;
			this.point_b = b;
		} this.point_a = a this.point_a this this.point_a a this.point_b = b this.point_b this this.point_b b int a a int b b public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	}

	static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	}

} public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	}

	static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	}

} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.List;

public class Main {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int w = Integer.parseInt(br.readLine());

		int n = Integer.parseInt(br.readLine());

		int[] ans = new int[w + 1];

		List<points> line = new ArrayList<>();

		for (int i = 0; i < n; i++) {
			String[] s_points = br.readLine().split(",");

			line.add(new points(Integer.parseInt(s_points[0]), Integer.parseInt(s_points[1])));
		}

		Deque<points> d = new ArrayDeque<>();

		for (int i = 1; i <= w; i++) {
			int target = i;
			d.addAll(line);
			while (!(d.isEmpty())) {
				points p = d.poll();

				if (target == p.point_a) {
					target = p.point_b;
				} else if (target == p.point_b) {
					target = p.point_a;
				}
				/* System.out.println(p.point_a+" "+p.point_b); */
			}
			ans[target] = i;
		}
		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}
	}

	static class points {
		int point_a;
		int point_b;

		public points(int a, int b) {
			this.point_a = a;
			this.point_b = b;
		}
	}

}