#include <iostream>
using namespace std;
int main(void){
    int bow, n, number[30]={}, a, b;
    char commma;
    cin >> bow >> n;
    for(int i=1; i<=bow; i++){
        number[i]=i;
    }
    for(int i=0; i<n; i++){
        cin >> a >> commma >> b;
        int tmp=number[a];
        number[a]=number[b];
        number[b]=tmp;
    }
    for(int i=1; i<=bow; i++){
        cout << number[i] << endl;
    }
    return 0;
}

