#include<cstdio>
int main(){
    int n,w;
    scanf("%d %d",&n, &w);
    int arr[n+1];
    for(int i=0; i<=n; i++)
        arr[i]=i;
    while(w--){
        char s[3];
        //scanf("%s", s);
        //int a=s[0]-'0', b=s[2]-'0';
        int a,b;
        scanf("%d,%d",&a,&b);
        //cin>>a>>,>>b;
        int memo=arr[a];
        arr[a]=arr[b];
        arr[b]=memo;
    }
    for(int i=1; i<=n; i++)
        printf("%d\n", arr[i]);
    return 0;
}
