import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int[] am = new int[32];
        int n,i,w,a,b,t;
        String st;
        String[] x;
        w = s.nextInt();
        n = s.nextInt();
        for(i=1;i<=w;i++)am[i]=i;
        for(i=1;i<=n;i++){
            st = s.next();
            x = st.split(",");
            a = Integer.parseInt(x[0]);
            b = Integer.parseInt(x[1]);
            t = am[a];
            am[a] = am[b];
            am[b] = t;
        }
        for(i=1;i<=w;i++)System.out.println(am[i]);
    }
}

/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz