#include<bits/stdc++.h>
using namespace std;

int c[32] = {0};

int main(){
    int w, n;
    cin >> w >> n;
    for(int i=1;i<=w;++i)
        c[i] = i;
    for(int i=0;i<n;++i){
        int a, b;
        scanf("%d,%d",&a,&b);
        int tmp;
        tmp = c[a];
        c[a] = c[b];
        c[b] = tmp;
    }
    for(int i=1;i<=w;++i)
        cout << c[i] << endl;

    return 0;
}
