import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    }

    static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    }

} import java.util.*; util.* java public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    }

    static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    }

} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    } main {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int h = sc.nextInt(); h sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc int w = sc.nextInt(); w sc.nextInt() sc.nextInt sc sc.nextLine() sc.nextLine sc int[] f = new int[w]; f new int[w] w int[] l = new int[w]; l new int[w] w for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        } int i = 0; int i = 0; i 0 i < w i w i++ i++ i {
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        } {
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        } String[] s = sc.nextLine().split(","); s sc.nextLine().split(",") sc.nextLine().split sc.nextLine() sc.nextLine sc "," f[i] = Integer.parseInt(s[0]) f[i] f i Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 l[i] = Integer.parseInt(s[1]) l[i] l i Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int[] result = new int[h]; result new int[h] h for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i; int i = 1; int i = 1; i 1 i <= h i h i++ i++ i result[amida(f,l,i) - 1] = i; result[amida(f,l,i) - 1] = i result[amida(f,l,i) - 1] result amida(f,l,i) - 1 amida(f,l,i) amida f l i 1 i for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]); int i = 0,size = result.length; int i = 0 i 0 size = result.length; size result.length result result.length i < size i size i++ i++ i System.out.println(result[i]); System.out.println(result[i]) System.out.println System.out System System.out result[i] result i String[] args args static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    } amida {
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    } for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        } int i = 0,size = f.length; int i = 0 i 0 size = f.length; size f.length f f.length i < size i size i++ i++ i {
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        } {
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        } if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i]; f[i] == index f[i] f i index index = l[i] index l[i] l i if(l[i] == index) index = f[i]; l[i] == index l[i] l i index index = f[i] index f[i] f i return index; index int[] f f int[] l l int index index public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    }

    static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    }

} public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    }

    static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    }

} Main
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        sc.nextLine();
        int w = sc.nextInt();
        sc.nextLine();
        int[] f = new int[w];
        int[] l = new int[w];
        for(int i = 0;i < w;i++){
            String[] s = sc.nextLine().split(",");
            f[i] = Integer.parseInt(s[0]);
            l[i] = Integer.parseInt(s[1]);
        }
        int[] result = new int[h];
        for(int i = 1;i <= h;i++) result[amida(f,l,i) - 1] = i;
        for(int i = 0,size = result.length;i < size;i++) System.out.println(result[i]);
    }

    static int amida(int[] f,int[] l,int index){
        for(int i = 0,size = f.length;i < size;i++){
            if(f[i] == index) index = l[i];
            else if(l[i] == index) index = f[i];
        }
        return index;
    }

}