#include <iostream>
#include <string>

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int amida[33];
    for (int i = 0; i <= 31; ++i)
        amida[i] = i;
    int w, n;
    int a, b;
    std::string s;
    std::cin >> w;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        std::cin >> s;
        a = s.at(0) - '0';
        b = s.at(2) - '0';
        amida[32] = amida[a];
        amida[a] = amida[b];
        amida[b] = amida[32];
    }
    for (int i = 1; i <= w; ++i)
        std::cout << amida[i] << std::endl;
}

