(n, m), result, stack = [int(i) for i in input().split()], [], [(False, 1, 0)]
g, visited = [[] for _ in range(n + 1)], [False] * (n + 1)
for x, y in (map(int, input().split()) for _ in range(m)): g[x].append(y), g[y].append(x)

while stack:
    delayed, v, depth = stack.pop()
    if delayed: result.append(v)
    elif not visited[v]:
        visited[v] = True
        if depth & 1: stack.append((True, v, None))  # Delay visiting cabins with odd distance to cabin 1
        for w in g[v]: stack.append((False, w, depth + 1))
        if depth & 1 == 0: result.append(v)  # Immediately visit cabins with even distance to cabin 1
print(*result)
