#include "bits/stdc++.h" using namespace std; #define ll long long void solve() { int n, m; cin >> n >> m; map>> a; for (int i = 0; i < m; i++) { int x1, x2; ll y; cin >> x1 >> y; cin >> x2 >> y; a[y].insert({x1, x2}); } vector hp(n); for (int i = 0; i < n; i++) hp[i] = i; for (auto &p : a) { auto s = p.second; for (auto gp : s) { swap(hp[gp.first - 1], hp[gp.second - 1]); } } vector h(n); for (int i = 0; i < n; i++) h[hp[i]] = i + 1; for (int x : h) cout << x << '\n'; } int main() { solve(); }