#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#else
#define DEBUG(...) 6
#endif
template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template <typename T, typename... Args> void debug(string s, T x, Args... args) {for (int i=0, b=0; i<(int)s.size(); i++) if (s[i] == '(' || s[i] == '{') b++; else
if (s[i] == ')' || s[i] == '}') b--; else if (s[i] == ',' && b == 0) {cerr << s.substr(0, i) << " = " << x << " | "; debug(s.substr(s.find_first_not_of(' ', i + 1)), args...); break;}}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(6);
int n, m;
cin >> n >> m;
vector<vector<int>> adj(n);
vector<vector<bool>> mat(n, vector<bool>(n));
for (int i=0; i<m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u].push_back(v);
adj[v].push_back(u);
mat[u][v] = mat[v][u] = true;
}
if (n <= 20) {
auto solve = [&] (auto &self, int u, int mask) -> bool {
if (mask == (1 << n) - 1) {
if (u == 0) {
cout << u + 1 << " ";
return true;
}
return false;
}
for (int v : adj[u])
if (~mask & (1 << v) && self(self, v, mask | (1 << v))) {
cout << u + 1 << " ";
return true;
}
return false;
};
solve(solve, 0, 0);
cout << "\n";
return 0;
}
for (int rep=0; rep<100; rep++) {
vector<int> ret(n);
iota(ret.begin() + 1, ret.end(), 1);
shuffle(ret.begin() + 1, ret.end(), rng);
ret.push_back(0);
bool done = false;
if (rep == 99)
done = true;
while (!done) {
done = true;
for (int i=0; i<n; i++)
if (!mat[ret[i]][ret[i+1]]) {
bool ok = false;
for (int j=i+1; j<n; j++)
if (mat[ret[j]][ret[j+1]] && mat[ret[i]][ret[j]] && mat[ret[i+1]][ret[j+1]]) {
reverse(ret.begin() + i + 1, ret.begin() + j + 1);
ok = true;
break;
}
if (!ok) {
for (int j=0; j+1<i; j++)
if (mat[ret[j]][ret[j+1]] && mat[ret[i]][ret[j]] && mat[ret[i+1]][ret[j+1]]) {
int l = i + 1, r = j;
vector<bool> vis(n);
while (!vis[l] && !vis[r]) {
swap(ret[l], ret[r]);
vis[l] = vis[r] = true;
if (++l == n)
l = 0;
if (--r == -1)
r = n - 1;
}
ret[n] = ret[0];
ok = true;
break;
}
if (!ok)
goto fail;
}
done = false;
}
}
for (int i=0; i<=n; i++)
cout << ret[i] + 1 << " ";
cout << "\n";
return 0;
fail:;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojaWZkZWYgTE9DQUwKI2RlZmluZSBERUJVRyguLi4pIGRlYnVnKCNfX1ZBX0FSR1NfXywgX19WQV9BUkdTX18pCiNlbHNlCiNkZWZpbmUgREVCVUcoLi4uKSA2CiNlbmRpZgoKdGVtcGxhdGU8dHlwZW5hbWUgVCwgdHlwZW5hbWUgUz4gb3N0cmVhbSYgb3BlcmF0b3IgPDwgKG9zdHJlYW0gJm9zLCBjb25zdCBwYWlyPFQsIFM+ICZwKSB7cmV0dXJuIG9zIDw8ICIoIiA8PCBwLmZpcnN0IDw8ICIsICIgPDwgcC5zZWNvbmQgPDwgIikiO30KdGVtcGxhdGU8dHlwZW5hbWUgQywgdHlwZW5hbWUgVCA9IGRlY2F5PGRlY2x0eXBlKCpiZWdpbihkZWNsdmFsPEM+KCkpKT4sIHR5cGVuYW1lIGVuYWJsZV9pZjwhaXNfc2FtZTxDLCBzdHJpbmc+Ojp2YWx1ZT46OnR5cGUqID0gbnVsbHB0cj4Kb3N0cmVhbSYgb3B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xpbnQ+PiBhZGoobik7CiAgICB2ZWN0b3I8dmVjdG9yPGJvb2w+PiBtYXQobiwgdmVjdG9yPGJvb2w+KG4pKTsKICAgIGZvciAoaW50IGk9MDsgaTxtOyBpKyspIHsKICAgICAgICBpbnQgdSwgdjsKICAgICAgICBjaW4gPj4gdSA+PiB2OwogICAgICAgIHUtLSwgdi0tOwogICAgICAgIGFkalt1XS5wdXNoX2JhY2sodik7CiAgICAgICAgYWRqW3ZdLnB1c2hfYmFjayh1KTsKICAgICAgICBtYXRbdV1bdl0gPSBtYXRbdl1bdV0gPSB0cnVlOwogICAgfQoKICAgIGlmIChuIDw9IDIwKSB7CiAgICAgICAgYXV0byBzb2x2ZSA9IFsmXSAoYXV0byAmc2VsZiwgaW50IHUsIGludCBtYXNrKSAtPiBib29sIHsKICAgICAgICAgICAgaWYgKG1hc2sgPT0gKDEgPDwgbikgLSAxKSB7CiAgICAgICAgICAgICAgICBpZiAodSA9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgY291dCA8PCB1ICsgMSA8PCAiICI7CiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZm9yIChpbnQgdiA6IGFkalt1XSkKICAgICAgICAgICAgICAgIGlmICh+bWFzayAmICgxIDw8IHYpICYmIHNlbGYoc2VsZiwgdiwgbWFzayB8ICgxIDw8IHYpKSkgewogICAgICAgICAgICAgICAgICAgIGNvdXQgPDwgdSArIDEgPDwgIiAiOwogICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfTsKICAgICAgICBzb2x2ZShzb2x2ZSwgMCwgMCk7CiAgICAgICAgY291dCA8PCAiXG4iOwogICAgICAgIHJldHVybiAwOwogICAgfQoKICAgIGZvciAoaW50IHJlcD0wOyByZXA8MTAwOyByZXArKykgewogICAgICAgIHZlY3RvcjxpbnQ+IHJldChuKTsKICAgICAgICBpb3RhKHJldC5iZWdpbigpICsgMSwgcmV0LmVuZCgpLCAxKTsKICAgICAgICBzaHVmZmxlKHJldC5iZWdpbigpICsgMSwgcmV0LmVuZCgpLCBybmcpOwogICAgICAgIHJldC5wdXNoX2JhY2soMCk7CiAgICAgICAgYm9vbCBkb25lID0gZmFsc2U7CiAgICAgICAgaWYgKHJlcCA9PSA5OSkKICAgICAgICAgICAgZG9uZSA9IHRydWU7CiAgICAgICAgd2hpbGUgKCFkb25lKSB7CiAgICAgICAgICAgIGRvbmUgPSB0cnVlOwogICAgICAgICAgICBmb3IgKGludCBpPTA7IGk8bjsgaSsrKQogICAgICAgICAgICAgICAgaWYgKCFtYXRbcmV0W2ldXVtyZXRbaSsxXV0pIHsKICAgICAgICAgICAgICAgICAgICBib29sIG9rID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaj1pKzE7IGo8bjsgaisrKQogICAgICAgICAgICAgICAgICAgICAgICBpZiAobWF0W3JldFtqXV1bcmV0W2orMV1dICYmIG1hdFtyZXRbaV1dW3JldFtqXV0gJiYgbWF0W3JldFtpKzFdXVtyZXRbaisxXV0pIHsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldmVyc2UocmV0LmJlZ2luKCkgKyBpICsgMSwgcmV0LmJlZ2luKCkgKyBqICsgMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBvayA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgICAgIGlmICghb2spIHsKICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChpbnQgaj0wOyBqKzE8aTsgaisrKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG1hdFtyZXRbal1dW3JldFtqKzFdXSAmJiBtYXRbcmV0W2ldXVtyZXRbal1dICYmIG1hdFtyZXRbaSsxXV1bcmV0W2orMV1dKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW50IGwgPSBpICsgMSwgciA9IGo7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmVjdG9yPGJvb2w+IHZpcyhuKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoIXZpc1tsXSAmJiAhdmlzW3JdKSB7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN3YXAocmV0W2xdLCByZXRbcl0pOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2aXNbbF0gPSB2aXNbcl0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKytsID09IG4pCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsID0gMDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKC0tciA9PSAtMSkKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHIgPSBuIC0gMTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0W25dID0gcmV0WzBdOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9rID0gdHJ1ZTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFvaykKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGdvdG8gZmFpbDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICAgICAgZG9uZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpPTA7IGk8PW47IGkrKykKICAgICAgICAgICAgY291dCA8PCByZXRbaV0gKyAxIDw8ICIgIjsKICAgICAgICBjb3V0IDw8ICJcbiI7CiAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgZmFpbDo7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0K