import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    }
}
 import java.util.Scanner; Scanner 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[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    }
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    } main {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    } 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[] a = new int[n]; a new int[n] n int[] b = new int[n]; b new int[n] n for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        } {
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        } String s = sc.next(); s sc.next() sc.next sc String[] S = s.split(","); S s.split(",") s.split s "," a[i] = Integer.parseInt(S[0]) a[i] a i Integer.parseInt(S[0]) Integer.parseInt Integer S[0] S 0 b[i] = Integer.parseInt(S[1]) b[i] b i Integer.parseInt(S[1]) Integer.parseInt Integer S[1] S 1 int[] ans = new int[w]; ans new int[w] w for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        } int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        } {
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        } int x = i + 1; x i + 1 i 1 for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            } {
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            } if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j]; a[j] == x a[j] a j x x = b[j] x b[j] b j if(b[j] == x) x = a[j]; b[j] == x b[j] b j x x = a[j] x a[j] a j ans[x - 1] = i + 1 ans[x - 1] ans x - 1 x 1 i + 1 i 1 for(int i = 0; i < w; i++){
            System.out.println(ans[i]);
        } int i = 0; int i = 0; i 0 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 sc.close() sc.close sc 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[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    }
} public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    }
} Main
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i = 0; i < n; i++){
            String s = sc.next();
            String[] S = s.split(",");
            a[i] = Integer.parseInt(S[0]);
            b[i] = Integer.parseInt(S[1]);
        }
        int[] ans = new int[w];
        for(int i = 0; i < w; i++){
            int x = i + 1;
            for(int j = 0; j < n; j++){
                if(a[j] == x) x = b[j];
                else if(b[j] == x) x = a[j];
            }
            ans[x - 1] = i + 1;
        }

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

        sc.close();
        
    }
}

