#include using namespace std; typedef long long ll; typedef pair pi; typedef vector vi; #define sz(x) ((ll)(x).size()) #define all(x) begin(x), end(x) #define rep(i, a, b) for(int i = a; i < (b); ++i) struct G { int x0, x1, y; bool operator<(const G &rhs) const { return y < rhs.y; } }; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin.exceptions(ios::failbit); int hunter_cnt, grooves_cnt; cin >> hunter_cnt >> grooves_cnt; vector grooves; grooves.reserve(grooves_cnt); for (int g = 0; g < grooves_cnt; ++g) { int xp, xq,y,_; cin >> xp >> y >> xq >> _; xp--; xq--; y--; grooves.push_back(G{xp, xq, y}); } sort(all(grooves)); vector borci; borci.reserve(hunter_cnt); for (int h = 0; h < hunter_cnt; ++h) { borci.emplace_back(h); } for (auto& groove : grooves) { ll b0, b1; b0 = borci.at(groove.x0); b1 = borci.at(groove.x1); borci.at(groove.x0) = b1; borci.at(groove.x1) = b0; } vector kde_borec_skoncil(hunter_cnt, -1); for (int idx = 0; idx < hunter_cnt; ++idx) { kde_borec_skoncil.at(borci.at(idx)) = idx; } for (ll skoncil : kde_borec_skoncil) { cout << (skoncil + 1) << '\n'; } }