#include using namespace std; using ll = long long; struct groove { ll x, y, height; groove() = default; groove(ll x, ll y, ll height) : x(x), y(y), height(height) {} bool operator<(const groove& other) const { return height < other.height; } }; int main() { ll n, m; cin >> n >> m; vector grooves(m); vector indexes(n); for (ll i = 0; i < n; ++i) { indexes[i] = i; } for (ll i = 0; i < m; ++i) { ll x, y, height; cin >> x >> height >> y >> height; grooves[i] = groove(x, y, height); } std::sort(grooves.begin(), grooves.end()); for (const groove & g : grooves) { std::swap(indexes[g.x - 1], indexes[g.y - 1]); } vector result(n); for (ll i = 0; i < n; ++i) { result[indexes[i]] = i; } for (ll i = 0; i < n; ++i) { cout << result[i] + 1 << '\n'; } return 0; }