#include <iostream>

using namespace std;

int main(){
    int w,n;
    int lots[30];

    cin>>w;
    for (int i=0;i<w;i++){
        lots[i]=i+1;
    }
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int a,b;

        scanf("%d,%d",&a,&b);
        swap(lots[a-1],lots[b-1]);
    }
    for (int j = 0; j < w; ++j) {
        cout<<lots[j]<<endl;
    }
    return 0;
}