#include #include #include #include using namespace std; using point = pair; int main() { size_t hunters, grooves; cin >> hunters >> grooves; map transport = map(); for (size_t g = 0; g < grooves; g++) { size_t x, y, ex, ey; cin >> x >> y >> ex >> ey; point start = point(x, y); point end = point(ex, ey); transport[start] = end; transport[end] = start; } point pos; for (size_t h = 1; h <= hunters; h++) { pos.first = h; pos.second = 0; while (true) { auto it = transport.lower_bound(pos); if (it->first.first != pos.first || it->first.second < pos.second) break; pos = it->second; pos.second++; } cout << pos.first << endl; } return 0; }