import java.util.Scanner;

public class Main {

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    }

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

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    }

    public static void main(String[] args) {
        Main main = new Main();
        main.DL();
    }
} Main public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    } DL {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int w = s.nextInt(); w s.nextInt() s.nextInt s int n = s.nextInt(); n s.nextInt() s.nextInt s 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 = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        } {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        } String[] input = s.next().split(","); input s.next().split(",") s.next().split s.next() s.next s "," int in0 = Integer.parseInt(input[0]); in0 Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int in1 = Integer.parseInt(input[1]); in1 Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 list1[i][in0] = in1 list1[i][in0] list1[i] list1 i in0 in1 list2[i][in1] = in0 list2[i][in1] list2[i] list2 i in1 in0 int[] a = new int[w + 1]; a new int[w + 1] w + 1 w 1 for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = 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 (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        } {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        } int p = i; p i for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            } int j = 0; int j = 0; j 0 j < n j n j++ j++ j {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            } {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            } if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                } list1[j][p] != 0 list1[j][p] list1[j] list1 j p 0 {
                    p = list1[j][p];
                } p = list1[j][p] p list1[j][p] list1[j] list1 j p if (list2[j][p] != 0) {
                    p = list2[j][p];
                } list2[j][p] != 0 list2[j][p] list2[j] list2 j p 0 {
                    p = list2[j][p];
                } p = list2[j][p] p list2[j][p] list2[j] list2 j p a[p] = i a[p] a p i for (int i = 1; i <= w; i++) {
            System.out.println(a[i]);
        } int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
            System.out.println(a[i]);
        } {
            System.out.println(a[i]);
        } System.out.println(a[i]) System.out.println System.out System System.out a[i] a i public static void main(String[] args) {
        Main main = new Main();
        main.DL();
    } main {
        Main main = new Main();
        main.DL();
    } Main main = new Main(); main new Main() main.DL() main.DL main String[] args args public class Main {

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    }

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

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    }

    public static void main(String[] args) {
        Main main = new Main();
        main.DL();
    }
} Main
import java.util.Scanner;

public class Main {

    public void DL() {
        Scanner s = new Scanner(System.in);
        int w = s.nextInt();
        int n = s.nextInt();
        int[][] list1 = new int[n][w + 1];
        int[][] list2 = new int[n][w + 1];

        for (int i = 0; i < n; i++) {
            String[] input = s.next().split(",");
            int in0 = Integer.parseInt(input[0]);
            int in1 = Integer.parseInt(input[1]);
            list1[i][in0] = in1;
            list2[i][in1] = in0;
        }

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

        for (int i = 1; i <= w; i++) {
            int p = i;
            for (int j = 0; j < n; j++) {
                if (list1[j][p] != 0) {
                    p = list1[j][p];
                } else if (list2[j][p] != 0) {
                    p = list2[j][p];
                }
            }
            a[p] = i;
        }

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

    }

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