#include #include #include #include int main ( ) { std::map,size_t> grooves; size_t n,m,xp,yp,xq,yq,x; std::cin >> n >> m; for (size_t i = 0; i < m; i++) { std::cin >> xp >> yp >> xq >> yq; grooves[{xp,yp}] = xq; grooves[{xq,yq}] = xp; } for (size_t i = 1; i <= n; i++) { x = i; for (size_t y = 0; y <= m; y++) { if (grooves.count({x,y})) { x = grooves[{x,y}]; } } std::cout << x << std::endl; } return 0; }