#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int s[31];
    for (int i=1; i<=30; ++i) {
        s[i] = i;
    }

    int w, n;
    cin >> w >> n;
    int a,b;
    char delim;
    for (int i=0; i<n; ++i) {
        cin >> a >> delim >> b;
        swap(s[a],s[b]);
    }

    for (int i=1; i<=n; ++i) {
        cout << s[i] << "\n";
    }

    return 0;
}