#include <iostream>

using namespace std;

int main(){
    int tate[30], w, n, a, b;
    char comma;
    for(int i=0;i<30;i++) tate[i]=i+1;
    
    cin >> w;
    cin >> n;
    
    for(int i=0;i<n;i++){
        cin >> a >> comma >> b;
        swap(tate[a-1],tate[b-1]);
    }
    
    for(int i=0;i<w;i++){
        cout << tate[i] << endl;
    }
    return 0;
}