#include typedef long long ll; using namespace std; int INF = 1e9; int MOD = 1e9+7; int boss[10000]; int cnt[10000]; int N,M; //lの値をwに void update(int l,int w,ll s){ for(int i = 0;i < N;i++){ if(boss[i] == w || boss[i] == l){ boss[i] = w; cnt[i] = s; } } } main(){ cin >> N >> M; for(int i = 0;i < N;i++){boss[i] = i+1;cnt[i] = 1;} for(int i = 0;i < M;i++){ int a,b; cin >> a >> b; int win,lose; if(boss[a-1] == boss[b-1])continue; if(cnt[a-1] == cnt[b-1]){ win = min(boss[a-1],boss[b-1]); lose = max(boss[a-1],boss[b-1]); }else{ if(cnt[a-1] > cnt[b-1]){ win = boss[a-1]; lose = boss[b-1]; }else{ win = boss[b-1]; lose = boss[a-1]; } } update(lose,win,cnt[a-1]+cnt[b-1]); } for(int i = 0;i < N;i++){ cout << boss[i] << endl; } }