#include <iostream>
#include <vector>
#include <algorithm>

bool comp(const std::tuple<int, int, int, int>& lhs, const std::tuple<int, int, int, int>& rhs)
{
    int lhs_yp = std::get<1>(lhs), rhs_yp = std::get<1>(rhs);
    return lhs_yp < rhs_yp;
}

void apply_grooves(std::vector<int>& arr, const std::vector<std::tuple<int, int, int, int>>& grooves){
    for (auto [xp, yp, xq, yq] : grooves) {
        std::swap(arr[xp-1], arr[xq-1]);
    }
}

int main() {
    int N, M;

    std::cin >> N >> M;
    std::vector<std::tuple<int, int, int, int>> grooves;

    for (int i = 0; i < M; ++i) {
        int xp, yp, xq, yq;
        std::cin >> xp >> yp >> xq >> yq;
        grooves.emplace_back(xp, yp, xq, yq);
    }

    std::sort(grooves.begin(), grooves.end(), comp);

    std::vector<int> arr(N);
    for (int i = 0; i < N; ++i) {
        arr[i] = i+1;
    }

    apply_grooves(arr, grooves);
    std::vector<int> res(N);
    for (int i = 0; i < N; ++i) {
        res[arr[i]-1] = i+1;
    }

    for (int i = 0; i < N; ++i) {
        std::cout << res[i];
        if (i != N-1)
            std::cout << "\n";
    }
}
