#include using namespace std; typedef long long ll; typedef pair P; const ll MOD = 1000000007; const int IINF = INT_MAX; const ll LLINF = LLONG_MAX; const int MAX_N = int(5e5 + 5); const double EPS = 1e-10; const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0}; #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define SORT(v) sort((v).begin(), (v).end()) #define ALL(v) (v).begin(), (v).end() struct UnionFindTree { vector par; vector rank; vector siz; void init(int n) { par.resize(n); rank.resize(n); siz.resize(n); for (int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; siz[i] = 1; } } int find(int x) { if (par[x] == x) { return x; } else { return par[x] = find(par[x]); } } void unite(int x, int y) { x = find(x); y = find(y); if (x == y) return; if(x>y)swap(x,y); if(size(x)> n >> m; g.init(n); REP(i,m){ int a, b; cin >> a >> b; a--; b--; g.unite(a,b); } REP(i,n){ cout << g.find(i)+1 << endl; } return 0; }