#include <iostream>
#include <vector>
#include <utility>

using namespace std;

int main(){
    int w,n;
    int i,j;
    char c;
    cin >> w;
    cin >> n;
    vector<pair<int,int> > yokos(n+1);
    vector<int> result(w);
    for(i=0;i<n;++i){
        cin >> yokos[i].first >> c >> yokos[i].second;
    }
    for(i=1;i<=w;++i){
        int current = i;
        for(j=0;j<n;++j){
            if(yokos[j].first == current)
                current = yokos[j].second;
            else if(yokos[j].second == current)
                current = yokos[j].first;
        }
        result[current-1] = i;
    }
    for(i=0;i<w;++i){
        cout << result[i] << endl;
    }

    return 0;
}