import java.util.*;
import java.lang.*;

/**
 * DrawingLots
 */
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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    }
} import java.util.*; util.* java import java.lang.*; lang.* 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 a[] = new int[n];
        int b[] = new int[n];

        for (int i = 0; i < n; i++) {
            String str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    }
} 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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    } 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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    } 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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            String str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        } {
            String str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        } String str = sc.next(); str sc.next() sc.next sc String list[] = str.split(","); list str.split(",") str.split str "," a[i] = Integer.valueOf(list[0]) a[i] a i Integer.valueOf(list[0]) Integer.valueOf Integer list[0] list 0 b[i] = Integer.valueOf(list[1]) b[i] b i Integer.valueOf(list[1]) Integer.valueOf Integer list[1] list 1 for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        } int i = 1; int i = 1; i 1 i <= w i w i++ i++ i {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        } {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        } int num = i; num i for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            } int j = n - 1; int j = n - 1; j n - 1 n 1 j >= 0 j 0 j-- j-- j {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            } {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            } if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                } a[j] == num a[j] a j num {
                    num = b[j];
                } num = b[j] num b[j] b j if (b[j] == num) {
                    num = a[j];
                } b[j] == num b[j] b j num {
                    num = a[j];
                } num = a[j] num a[j] a j System.out.println(num) System.out.println System.out System System.out num 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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    }
} 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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    }
} Main
import java.util.*;
import java.lang.*;

/**
 * DrawingLots
 */
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 str = sc.next();
            String list[] = str.split(",");
            a[i] = Integer.valueOf(list[0]);
            b[i] = Integer.valueOf(list[1]);
        }

        for (int i = 1; i <= w; i++) {
            int num = i;
            for (int j = n - 1; j >= 0; j--) {
                if (a[j] == num) {
                    num = b[j];
                } else if (b[j] == num) {
                    num = a[j];
                }
            }
            System.out.println(num);
        }
    }
}
