#include #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; int par[10000],s[10000]; int find(int x){ if(x==par[x])return x; return par[x]=find(par[x]); } void unite(int x,int y){ par[x]=y; s[y]+=s[x]; } int main() { int n,m;scanf("%d%d",&n,&m); rep(i,n)par[i]=i,s[i]=1; rep(i,m){ int a,b;scanf("%d%d",&a,&b);a--;b--; a=find(a);b=find(b); if(a==b)continue; if(s[a]!=s[b]){ if(s[a]b)unite(a,b); else unite(b,a); } } rep(i,n)printf("%d\n",find(i)+1); }