#include using namespace std; #define ll long long void testcase() { int n,m; cin >> n >> m; map> grooves; for (ll i = 0; i < m; ++i) { ll xp, yp, xq, yq; cin >> xp >> yp >> xq >> yq; grooves.insert({yp, make_pair(xp, xq)}); } vector hunters(n); for (ll i = 0; i < n; ++i) { hunters[i] = i+1; } for (ll y = 0; y < m; ++y) { if (grooves.find(y+1) != grooves.end()) { auto& groove = grooves[y+1]; for (ll hi = 0; hi < n; ++hi) { if (hunters[hi] == groove.first) { hunters[hi] = groove.second; } else if (hunters[hi] == groove.second) { hunters[hi] = groove.first; } } } } for (ll i = 0; i < n; ++i) { cout << hunters[i] << "\n"; } } int main() { testcase(); }