#include <cstdio>
#include <algorithm>

using namespace std;

int main(void) {
    int w, n, a, b;
    scanf("%d%d", &w, &n);
    int x[w];
    for (int i = 0; i < w; i++) x[i] = i + 1;
    for (int i = n; i--;) {
        scanf("%d,%d", &a, &b);
        swap(x[a - 1], x[b - 1]);
    }
    for (int i = 0; i < w; i++) printf("%d\n", x[i]);
    return 0;
}