#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<utility>
using namespace std;

int main(){
    int w, n;
    cin >> w >> n;

    vector<int> ans;
    for(int i = 0 ; i <= w ; ++i){
        ans.emplace_back(i);
    }

    for(int i = 0 ; i < n ; ++i){
        int a, b;
        char c;
        cin >> a >> c >> b;
        swap(ans[a], ans[b]);
    }

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

    return 0;
}
