#include #include #include bool comp(const std::tuple& lhs, const std::tuple& rhs) { int lhs_yp = std::get<1>(lhs), rhs_yp = std::get<1>(rhs); return lhs_yp < rhs_yp; } void apply_grooves(std::vector& arr, const std::vector>& 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> 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 arr(N); for (int i = 0; i < N; ++i) { arr[i] = i+1; } apply_grooves(arr, grooves); std::vector 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"; } }