#include <iostream>
#include <deque>
#include <string>
#include <cstdio>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

int main(){
    int w, n;
    cin >> w >> n;

    int vec[40];
    for (int i = 0; i < 40; i++)vec[i] = i;
    for (int i = 0; i < n; i++){
        int a, b;
        char com;
        cin >> a >> com >> b;
        int t = vec[a];
        vec[a] = vec[b];
        vec[b] = t;
    }
    for (int i = 1; i <= w; i++){
        cout << vec[i] << endl;
    }
}