#include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; typedef vector vii; struct groove { unsigned y, x1, x2; bool operator<(const groove & other) const{ return y > other.y; } }; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); unsigned hunters, groovesn; cin >> hunters >> groovesn; vector targets(hunters); vector grooves; grooves.reserve(groovesn); for (unsigned i = 0; i < hunters; ++i) targets[i] = i; while (groovesn--){ unsigned y, _, x1, x2; cin >> x1 >> y >> x2 >> _; grooves.push_back({y, x1 - 1, x2 - 1}); } std::sort(grooves.begin(), grooves.end()); for (const groove & gr : grooves){ unsigned tmp1 = targets[gr.x1], tmp2 = targets[gr.x2]; targets[gr.x1] = tmp2, targets[gr.x2] = tmp1; } for (const unsigned res : targets) cout << res + 1 << endl; }