#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
const int MOD = 1e9 + 7 ;
int n , m , ans = 1 ;
int parent[1005], sz[1005] , bac[1005];
bool visited[1005];
int Find(int u){
if(u == parent[u]) return u;
else return Find(parent[u]);
}
void Union(int x , int y){
x = Find(x);
y = Find(y);
if(x == y) return ;
else{
if(bac[x] > bac[y] || bac[x] == bac[y] && x < y){
parent[y] = x ;
}
else{
parent[x] = y ;
}
}
}
void solve(){
cin >> n >> m ;
for(int i = 1 ; i <= n ; i++){
parent[i] = i ;
sz[i] = 1;
}
vector<pair<int,int> > v ;
for(int i = 1 ; i <= m ; i++){
int x , y ; cin >> x >> y ;
v.push_back({x , y});
bac[x]++;
bac[y]++;
}
// cout << ans << endl;
for(auto edge : v){
Union(edge.first , edge.second);
}
for(int i = 1 ; i <= n ; i++){
if(i == parent[i]){
cout << i << " ";
}
}
}
signed main() {
faster();
int test = 1 ;
// cin >> test ;
while(test--) solve();
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgZW5kbCAiXG4iCiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGZhc3RlcigpIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZShudWxscHRyKTsgY291dC50aWUobnVsbHB0cik7CmNvbnN0IGludCBNT0QgPSAxZTkgKyA3IDsKCmludCBuICAsIG0gLCBhbnMgPSAxIDsKaW50IHBhcmVudFsxMDA1XSwgc3pbMTAwNV0gLCBiYWNbMTAwNV07CmJvb2wgdmlzaXRlZFsxMDA1XTsKCmludCBGaW5kKGludCB1KXsKICAgIGlmKHUgPT0gcGFyZW50W3VdKSByZXR1cm4gdTsKICAgIGVsc2UgcmV0dXJuIEZpbmQocGFyZW50W3VdKTsKfQoKdm9pZCBVbmlvbihpbnQgeCAsIGludCB5KXsKICAgIHggPSBGaW5kKHgpOwogICAgeSA9IEZpbmQoeSk7CiAgICBpZih4ID09IHkpIHJldHVybiAgOwogICAgZWxzZXsKICAgICAgICBpZihiYWNbeF0gPiBiYWNbeV0gfHwgYmFjW3hdID09IGJhY1t5XSAmJiB4IDwgeSl7CiAgICAgICAgICAgIHBhcmVudFt5XSA9IHggOwogICAgICAgIH0KICAgICAgICBlbHNlewogICAgICAgICAgICBwYXJlbnRbeF0gPSB5IDsKICAgICAgICB9CiAgICB9Cn0KCnZvaWQgc29sdmUoKXsKICAgIGNpbiA+PiBuID4+IG0gOwoKICAgIGZvcihpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspewogICAgICAgIHBhcmVudFtpXSA9IGkgOwogICAgICAgIHN6W2ldID0gMTsKICAgIH0KCiAgICB2ZWN0b3I8cGFpcjxpbnQsaW50PiA+IHYgOwogICAgZm9yKGludCBpID0gMSA7IGkgPD0gbSA7IGkrKyl7CiAgICAgICAgaW50IHggLCB5IDsgY2luID4+IHggPj4geSA7CiAgICAgICAgdi5wdXNoX2JhY2soe3ggLCB5fSk7CiAgICAgICAgYmFjW3hdKys7CiAgICAgICAgYmFjW3ldKys7CiAgICB9CiAgICAvLyBjb3V0IDw8IGFucyA8PCBlbmRsOwoKICAgIGZvcihhdXRvIGVkZ2UgOiB2KXsKICAgICAgICBVbmlvbihlZGdlLmZpcnN0ICwgZWRnZS5zZWNvbmQpOwogICAgfQoKICAgIGZvcihpbnQgaSA9IDEgOyBpIDw9IG4gOyBpKyspewogICAgICAgIGlmKGkgPT0gcGFyZW50W2ldKXsKICAgICAgICAgICAgY291dCA8PCBpIDw8ICIgIjsKICAgICAgICB9CiAgICB9Cn0KCnNpZ25lZCBtYWluKCkgewogICAgZmFzdGVyKCk7IAogICAgaW50IHRlc3QgPSAxIDsgCiAgICAvLyBjaW4gPj4gdGVzdCA7CiAgICB3aGlsZSh0ZXN0LS0pICAgc29sdmUoKTsKICAgIHJldHVybiAwOwp9Cgo=