#include "bits/stdc++.h" using namespace std; #define ll long long void solve() { int n, m; cin >> n >> m; vector>> gy(n + 1, set>()); for (int i = 0; i < m; i++) { int y; ll x1, x2; cin >> x1 >> y >> x2 >> y; gy[y].insert({x1, x2}); } set> hx; for (int i = 0; i < n; i++) hx.insert({i + 1, i}); for (auto& s : gy) { for (auto p : s) { set iv; auto it = hx.lower_bound({p.first, -1}); while (it != hx.end() && it->first == p.first) { int i = it->second; iv.insert(i); hx.erase(it); hx.insert({p.second, i}); it = hx.lower_bound({p.first, i + 1}); } it = hx.lower_bound({p.second, -1}); while (it != hx.end() && it->first == p.second) { int i = it->second; if (iv.find(i) != iv.end()) { it = hx.lower_bound({p.second, i + 1}); continue; } hx.erase(it); hx.insert({p.first, i}); it = hx.lower_bound({p.second, i + 1}); } } } vector h(n); for (auto p : hx) { h[p.second] = p.first; } for (ll x : h) cout << x << '\n'; } int main() { solve(); }