#include <bits/stdc++.h>
using namespace std;
int main(void){
    int w,n,a,b;
    char c;
    std::deque<int> deq;
    cin >> w;
    for (int i=1;i<w+1;i++) {
        deq[i]=i;
    }
    cin >> n;
    for (int j=0;j<n;j++) {
        cin >> a >> c >> b;
        /*
        int a = x.at(0)-48;
        int b = x.at(2)-48;
        int tmp = deq[b];
        deq[b] = deq[a];
        deq[a] = tmp;*/
        swap(deq[a],deq[b]);
    }
    for (int k=1;k<w+1;k++) {
        cout << deq[k] << endl;
    }
    deq.clear();
}

