#include <bits/stdc++.h>
inline long long read() {
  long long sign = 1;
  long long x = 0;
  char ch;
  while (!isdigit(ch = getchar()))
    if (ch == '-') sign = -1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  return x * sign;
}
inline void wonl() { putchar('\n'); }
inline void ww(long long k) {
  if (k < 0) putchar('-'), k *= -1;
  char ch[20];
  int num = 0;
  while (k) ch[++num] = k % 10, k /= 10;
  if (num == 0) ch[++num] = 0;
  while (num) putchar(ch[num--] + '0');
}
using namespace std;
const int N = 1e5 + 4;
template <typename T, typename... V>
inline void wonl(T t, V... v) {
  ww(t);
  if (sizeof...(v)) putchar(' ');
  wonl(v...);
}
vector<int> v[N];
bool vis[N];
int ans[N], it = 0, val;
set<int> se;
void dfs(int s) {
  vis[s] = true;
  ans[it++] = s;
  for (auto x : v[s])
    if (!vis[x]) se.insert(x);
  while (se.size() > 0) val = *se.begin(), se.erase(val), dfs(val);
}
void inpgraph(int m) {
  int a, b;
  while (m--) a = read(), b = read(), v[a].push_back(b), v[b].push_back(a);
}
void solve() {
  int n = read(), m = read();
  inpgraph(m);
  dfs(1);
  for (int i = 0; i < n; i++) ww(ans[i]), putchar(' ');
}
int main() {
  solve();
  return 0;
}
