import java.util.*;

public class Main {

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

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
} import java.util.*; util.* java public class Main {

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

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	} main {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	} 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[][] map = new int[n][w+1]; map new int[n][w+1] n w+1 w 1 int[] ans = new int[w+1]; ans new int[w+1] w+1 w 1 for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		} {
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		} String s = sc.next(); s sc.next() sc.next sc int a a b; b if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			} s.substring(1,2).compareTo(",")==0 s.substring(1,2).compareTo(",") s.substring(1,2).compareTo s.substring(1,2) s.substring s 1 2 "," 0 {
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			} a = Integer.valueOf(s.substring(0,1)) a Integer.valueOf(s.substring(0,1)) Integer.valueOf Integer s.substring(0,1) s.substring s 0 1 b = Integer.valueOf(s.substring(2,s.length())) b Integer.valueOf(s.substring(2,s.length())) Integer.valueOf Integer s.substring(2,s.length()) s.substring s 2 s.length() s.length s {
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			} a = Integer.valueOf(s.substring(0,2)) a Integer.valueOf(s.substring(0,2)) Integer.valueOf Integer s.substring(0,2) s.substring s 0 2 b = Integer.valueOf(s.substring(3,s.length())) b Integer.valueOf(s.substring(3,s.length())) Integer.valueOf Integer s.substring(3,s.length()) s.substring s 3 s.length() s.length s map[i][a]=b map[i][a] map[i] map i a b map[i][b]=a map[i][b] map[i] map i b a for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		} int i=1; int i=1; i 1 i<=w i w i++ i++ i {
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		} {
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		} int k = i; k i for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			} int j=0; int j=0; j 0 j<n j n j++ j++ j {
				if(map[j][k]>0){
					k = map[j][k];
				}
			} {
				if(map[j][k]>0){
					k = map[j][k];
				}
			} if(map[j][k]>0){
					k = map[j][k];
				} map[j][k]>0 map[j][k] map[j] map j k 0 {
					k = map[j][k];
				} k = map[j][k] k map[j][k] map[j] map j k ans[k] = i ans[k] ans k i for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		} int i=0; int i=0; i 0 i<w i w i++ i++ i {
			System.out.println(ans[i+1]);
		} {
			System.out.println(ans[i+1]);
		} System.out.println(ans[i+1]) System.out.println System.out System System.out ans[i+1] ans i+1 i 1 String[] args args public class Main {

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

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
} public class Main {

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

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
} Main
import java.util.*;

public class Main {

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

		int w = sc.nextInt();
		int n = sc.nextInt();
		int[][] map = new int[n][w+1];
		int[] ans = new int[w+1];
		for(int i=0;i<n;i++){
			String s = sc.next();
			int a, b;
			if(s.substring(1,2).compareTo(",")==0){
				a = Integer.valueOf(s.substring(0,1));
				b = Integer.valueOf(s.substring(2,s.length()));
			}else{
				a = Integer.valueOf(s.substring(0,2));
				b = Integer.valueOf(s.substring(3,s.length()));
			}
			map[i][a]=b;
			map[i][b]=a;
		}
		for(int i=1;i<=w;i++){
			int k = i;
			for(int j=0;j<n;j++){
				if(map[j][k]>0){
					k = map[j][k];
				}
			}
			ans[k] = i;
		}
		for(int i=0;i<w;i++){
			System.out.println(ans[i+1]);
		}
		
		
	}
}