#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define swap(a,b) a^=b^=a^=b

using namespace std;

typedef struct{
    int l;
    int r;
}tint;
int main(){
    
    vector<tint> lines;
    tint ins;
    int w,n;
    cin >> w >> n;
    int *ans = new int(w+1);

    for(int i=0;i<n;i++){
        scanf("%d,%d",&ins.l,&ins.r);
        lines.push_back(ins);
    }
    for(int i=0;i<=w;i++){
        ans[i]=i;
    }
    for(int i=0;i<n;i++){
        swap(ans[lines[i].l],ans[lines[i].r]);
    }

    for(int i=1;i<=w;i++){
        cout << ans[i] << endl;
    }
    delete ans;
    
}