import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w = Integer.parseInt(sc.nextLine());
	static int[] res = new int[w];
	static int n = Integer.parseInt(sc.nextLine());
	static ArrayList<HorizLine> hL = new ArrayList<HorizLine>();

	public static void main(String[] args) {
		setHorizLine();
		drawLot();
	}

	private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	}

	private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	}



}

 class HorizLine {
	private int pointL;
	private int pointR;

	HorizLine(int pointL, int pointR) {
		this.pointL = pointL;
		this.pointR = pointR;
	}

	public int getPointL() {
		return pointL;
	}
	public int getPointR() {
		return pointR;
	}
	public void setPointL(int pointL) {
		this.pointL = pointL;
	}
	public void setPointR(int pointR) {
		this.pointR = pointR;
	}


} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w = Integer.parseInt(sc.nextLine());
	static int[] res = new int[w];
	static int n = Integer.parseInt(sc.nextLine());
	static ArrayList<HorizLine> hL = new ArrayList<HorizLine>();

	public static void main(String[] args) {
		setHorizLine();
		drawLot();
	}

	private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	}

	private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	}



} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int w = Integer.parseInt(sc.nextLine()); w Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc static int[] res = new int[w]; res new int[w] w static int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc static ArrayList<HorizLine> hL = new ArrayList<HorizLine>(); hL new ArrayList<HorizLine>() public static void main(String[] args) {
		setHorizLine();
		drawLot();
	} main {
		setHorizLine();
		drawLot();
	} setHorizLine() setHorizLine drawLot() drawLot String[] args args private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	} drawLot {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	} for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		} int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		} {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		} int p = i; p i for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			} int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			} {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			} if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					} p == hL.get(j).getPointL() p hL.get(j).getPointL() hL.get(j).getPointL hL.get(j) hL.get hL j {
						p = hL.get(j).getPointR();
					} p = hL.get(j).getPointR() p hL.get(j).getPointR() hL.get(j).getPointR hL.get(j) hL.get hL j if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					} p == hL.get(j).getPointR() p hL.get(j).getPointR() hL.get(j).getPointR hL.get(j) hL.get hL j {
						p = hL.get(j).getPointL();
					} p = hL.get(j).getPointL() p hL.get(j).getPointL() hL.get(j).getPointL hL.get(j) hL.get hL j res[p - 1] = i res[p - 1] res p - 1 p 1 i for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		} int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
			System.out.println(res[i]);
		} {
			System.out.println(res[i]);
		} System.out.println(res[i]) System.out.println System.out System System.out res[i] res i private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	} setHorizLine {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	} for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		} {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		} String[] pt = sc.nextLine().split(","); pt sc.nextLine().split(",") sc.nextLine().split sc.nextLine() sc.nextLine sc "," hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) )) hL.add hL new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ) class HorizLine {
	private int pointL;
	private int pointR;

	HorizLine(int pointL, int pointR) {
		this.pointL = pointL;
		this.pointR = pointR;
	}

	public int getPointL() {
		return pointL;
	}
	public int getPointR() {
		return pointR;
	}
	public void setPointL(int pointL) {
		this.pointL = pointL;
	}
	public void setPointR(int pointR) {
		this.pointR = pointR;
	}


} HorizLine private int pointL; pointL private int pointR; pointR HorizLine(int pointL, int pointR) {
		this.pointL = pointL;
		this.pointR = pointR;
	} HorizLine {
		this.pointL = pointL;
		this.pointR = pointR;
	} this.pointL = pointL this.pointL this this.pointL pointL this.pointR = pointR this.pointR this this.pointR pointR int pointL pointL int pointR pointR public int getPointL() {
		return pointL;
	} getPointL {
		return pointL;
	} return pointL; pointL public int getPointR() {
		return pointR;
	} getPointR {
		return pointR;
	} return pointR; pointR public void setPointL(int pointL) {
		this.pointL = pointL;
	} setPointL {
		this.pointL = pointL;
	} this.pointL = pointL this.pointL this this.pointL pointL int pointL pointL public void setPointR(int pointR) {
		this.pointR = pointR;
	} setPointR {
		this.pointR = pointR;
	} this.pointR = pointR this.pointR this this.pointR pointR int pointR pointR public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w = Integer.parseInt(sc.nextLine());
	static int[] res = new int[w];
	static int n = Integer.parseInt(sc.nextLine());
	static ArrayList<HorizLine> hL = new ArrayList<HorizLine>();

	public static void main(String[] args) {
		setHorizLine();
		drawLot();
	}

	private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	}

	private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	}



} public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w = Integer.parseInt(sc.nextLine());
	static int[] res = new int[w];
	static int n = Integer.parseInt(sc.nextLine());
	static ArrayList<HorizLine> hL = new ArrayList<HorizLine>();

	public static void main(String[] args) {
		setHorizLine();
		drawLot();
	}

	private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	}

	private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	}



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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int w = Integer.parseInt(sc.nextLine());
	static int[] res = new int[w];
	static int n = Integer.parseInt(sc.nextLine());
	static ArrayList<HorizLine> hL = new ArrayList<HorizLine>();

	public static void main(String[] args) {
		setHorizLine();
		drawLot();
	}

	private static void drawLot() {
		for (int i = 1; i <= w; i++) {
			int p = i;
			for (int j = 0; j < n; j++) {
					if (p == hL.get(j).getPointL() ) {
						p = hL.get(j).getPointR();
					} else if (p == hL.get(j).getPointR()) {
						p = hL.get(j).getPointL();
					}
			}

			res[p - 1] = i;
		}

		for (int i = 0; i < w; i++) {
			System.out.println(res[i]);
		}

	}

	private static void setHorizLine() {
		for (int i = 0; i < n; i++) {
			String[] pt = sc.nextLine().split(",");
			hL.add(new HorizLine( Integer.parseInt(pt[0]), Integer.parseInt(pt[1]) ));
		}

	}



}

 class HorizLine {
	private int pointL;
	private int pointR;

	HorizLine(int pointL, int pointR) {
		this.pointL = pointL;
		this.pointR = pointR;
	}

	public int getPointL() {
		return pointL;
	}
	public int getPointR() {
		return pointR;
	}
	public void setPointL(int pointL) {
		this.pointL = pointL;
	}
	public void setPointR(int pointR) {
		this.pointR = pointR;
	}


}
