#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+1; } for (ll i = 0; i < m; ++i) { auto& groove = grooves[i]; for (ll hi = 0; hi < n; ++hi) { if (hunters[hi] == groove.xp) { hunters[hi] = groove.xq; } else if (hunters[hi] == groove.xq) { hunters[hi] = groove.xp; } } } for (ll i = 0; i < n; ++i) { cout << hunters[i] << "\n"; } } int main() { testcase(); }