#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
using namespace std;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
int main(){
    int w,n;
    cin >> w >> n;
    vector<int> vec;
    rep(i,w){
        vec.push_back(i+1);
    }
    rep(i,n){
        int a,b;
        scanf("%d,%d",&a,&b);
        a--; b--;
        //cout << a << " " << b << endl;;
        swap(vec[a],vec[b]);
    }
    rep(i,w) cout << vec[i] << endl;
    return 0;
}
