#include using namespace std; #define ll long long struct groove { ll xp, xq, y; }; bool operator< (const groove& a, const groove& b) { return a.y < b.y; } int compare(const groove& a, const groove& b) { return b.y - a.y; } void testcase() { int n,m; cin >> n >> m; vector grooves(m); for (ll i = 0; i < m; ++i) { ll xp, yp, xq, yq; cin >> xp >> yp >> xq >> yq; grooves[i] = {xp, xq, yp}; } sort(grooves.begin(), grooves.end()); vector hunters(n); for (ll i = 0; i < n; ++i) { hunters[i] = i; } for (ll i = 0; i < m; ++i) { auto& groove = grooves[i]; // cout << "y, xp, xq" << groove.y << " " << groove.xp << " " << groove.xq << "\n"; // cout << "hunter at xp " << hunters[groove.xp - 1] << " hunter at xq " << hunters[groove.xq - 1] << "\n"; swap(hunters[groove.xp - 1], hunters[groove.xq - 1]); } vector final_pos(n + 1); for(ll i = 0; i < n; ++i) { final_pos[hunters[i]] = i + 1; } for (ll i = 0; i < n; ++i) { cout << final_pos[i] << "\n"; } } int main() { testcase(); }