#include <iostream>
#include <cstdio>

int main(int argc, const char * argv[])
{
    int w, n;
    std::cin >> w >> n;
    int a[w];
    for (int i = 0; i < w; i++) {
        a[i] = i + 1;
    }
    for (int i = 0; i < n; i++) {
        int aa, bb, tmp;
        scanf("%d,%d", &aa, &bb);
        tmp = a[aa - 1];
        a[aa - 1] = a[bb - 1];
        a[bb - 1] = tmp;
    }
    for (int i = 0; i < w; i++) {
        printf("%d\n", a[i]);
    }
    
    return 0;
}