#include <iostream>
using namespace std;
int main(void){
    int w,n,t[31][31],a,b,i,j;
    char ch;
    for(i = 0; i < 31; i++){
        for(j = 0; j < 31; j++){
            t[i][j] = j;
        }
    } 
    cin >> w >> n;
    for(i = 1; i <= n; i++){
        cin >> a >> ch >> b;
        t[i][a] = b;
        t[i][b] = a;
    }
    for(j = 1; j <= w; j++){
        a = j;
        for(i = n; i >= 0; i--){
            a = t[i][a];
        }
        cout << a << endl;
    }
}
