#include <iostream>

using namespace std;

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

    int lot[w + 1][n];
    fill(lot[0], lot[w + 1], 0);

    int a, b;
    char c;
    for (int i = 0; i < n; i++) {
        cin >> a >> c >> b;
        lot[a][i] = b;
        lot[b][i] = a;
    }

    int ans[w + 1];
    for (int i = 1; i <= w; i++) {
        int i_ = i;
        for (int j = 0; j < n; j++) {
            if (lot[i_][j] != 0) i_ = lot[i_][j];
        }
        ans[i_] = i;
    }
    for (int i = 1; i <= w; i++) {
        cout << ans[i] << endl;
    }
}
