import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
} import java.util.*; util.* java public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
} Main public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	} doIt {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int [][] list1 = new int[n][w+1]; list1 new int[n][w+1] n w+1 w 1 int [][] list2 = new int[n][w+1]; list2 new int[n][w+1] n w+1 w 1 for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		} int i=0; int i=0; i 0 i < n i n i++ i++ i {
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		} {
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		} String [] input = sc.next().split(","); input sc.next().split(",") sc.next().split sc.next() sc.next sc "," int input0 = Integer.parseInt(input[0]); input0 Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int input1 = Integer.parseInt(input[1]); input1 Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 list1[i][input0] = input1 list1[i][input0] list1[i] list1 i input0 input1 list2[i][input1] = input0 list2[i][input1] list2[i] list2 i input1 input0 int [] ans = new int[w+1]; ans new int[w+1] w+1 w 1 for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		} int i=1; int i=1; i 1 i <= w i w i++ i++ i {
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		} {
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		} int patt = i; patt i for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			} int j=0; int j=0; j 0 j < n j n j++ j++ j {
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			} {
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			} if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				} list1[j][patt] != 0 list1[j][patt] list1[j] list1 j patt 0 {
					patt = list1[j][patt];
				} patt = list1[j][patt] patt list1[j][patt] list1[j] list1 j patt if(list2[j][patt] != 0){
					patt = list2[j][patt];
				} list2[j][patt] != 0 list2[j][patt] list2[j] list2 j patt 0 {
					patt = list2[j][patt];
				} patt = list2[j][patt] patt list2[j][patt] list2[j] list2 j patt ans[patt] = i ans[patt] ans patt 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 public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	} main {
		Main obj = new Main();
		obj.doIt();
	} Main obj = new Main(); obj new Main() obj.doIt() obj.doIt obj String[] args args public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
} public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
} Main
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int [][] list1 = new int[n][w+1];
		int [][] list2 = new int[n][w+1];
		for(int i=0; i < n; i++){
			String [] input = sc.next().split(",");
			int input0 = Integer.parseInt(input[0]);
			int input1 = Integer.parseInt(input[1]);
			list1[i][input0] = input1;
			list2[i][input1] = input0;
		}
		int [] ans = new int[w+1];
		for(int i=1; i <= w; i++){
			int patt = i;
			for(int j=0; j < n; j++){
				if(list1[j][patt] != 0){
					patt = list1[j][patt];
				}
				else if(list2[j][patt] != 0){
					patt = list2[j][patt];
				}
			}
			ans[patt] = i;
		}

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

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doIt();
	}
}