#include #include #include #include using namespace std; typedef pair Coords; int main() { int numHunt, numGroov; cin >> numHunt >> numGroov; map grooves; int yMax = -1; for (int i = 0; i < numGroov; ++i) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; Coords c1(x1, y1); Coords c2(x2, y2); grooves[c1] = c2; grooves[c2] = c1; yMax = max(yMax, y1); } //cout << "numhunt " << numHunt << endl; for (int i = 1; i <= numHunt; ++i) { int hx = i; int hy = 0; while (hy <= yMax) { hy++; auto pos = grooves.find({hx, hy}); if (pos != grooves.end()) { hx = pos->second.first; } } cout << hx << endl; } return 0; }