#include <bits/stdc++.h>

const static int MAX = 31;

int main()
{

    int N, M, x, y;
    char c;
    std::scanf("%d", &N);
    int arr[N];
    for (int i = 1; i <= N; i++) arr[i] = i;
    std::scanf("%d", &M);
    for (int i = 0; i < M; i++) {
        std::scanf("%d%c%d", &x, &c, &y);
        std::swap(arr[x], arr[y]);
    }
    for (int i = 1; i <= N; i++) std::printf("%d\n", arr[i]);

    return 0;
}

