#include <stdio.h>
// 4508. 회의 준비
typedef struct {
int data[100];
int size;
} Stack;
typedef struct {
int data[100];
int front, rear;
} Queue;
int n;
int connections[101][101] = {0};
void stackPush(Stack* stackPtr, int value) {
stackPtr->data[stackPtr->size++] = value;
}
int stackPop(Stack* stackPtr) {
return stackPtr->data[--stackPtr->size];
}
int stackTop(Stack stack) {
return stack.data[stack.size - 1];
}
void enqueue(Queue* queuePtr, int value) {
queuePtr->data[queuePtr->rear++] = value;
}
int dequeue(Queue* queuePtr) {
return queuePtr->data[queuePtr->front++];
}
int queueSize(Queue queue) {
return queue.rear - queue.front;
}
int getDepth(int start) {
Queue queue = {{0}, 0, 0};
int checked[101] = {0};
int depth, node;
enqueue(&queue, start);
checked[start] = 1;
for (depth = -1; queueSize(queue) > 0; depth++) {
for (int i = queueSize(queue); i > 0; i--) {
node = dequeue(&queue);
for (int j = 1; j <= n; j++) {
if (connections[node][j] && !checked[j]) {
enqueue(&queue, j);
checked[j] = 1;
}
}
}
}
return depth;
}
int main() {
int m, a, b;
Stack stack = {{0}, 0};
scanf("%d\n%d", &n, &m);
for (int i = 0; i < m; i++) {
scanf("%d %d", &a, &b);
connections[a][b] = 1;
connections[b][a] = 1;
}
int checked[101] = {0};
int groupCount = 0;
int isACenterNode[101] = {0};
int centerNode, minDepth, depth;
for (int i = 1; i <= n; i++) {
if (checked[i]) {
continue;
}
groupCount += 1;
centerNode = 0;
minDepth = 200;
stackPush(&stack, i);
while (stack.size > 0) {
if (!checked[stackTop(stack)]) {
depth = getDepth(stackTop(stack));
if (depth < minDepth) {
centerNode = stackTop(stack);
minDepth = depth;
}
checked[stackTop(stack)] = 1;
}
for (int j = 1; j <= n; j++) {
if (connections[stackTop(stack)][j] && !checked[j]) {
stackPush(&stack, j);
break;
}
}
if (checked[stackTop(stack)]) {
stackPop(&stack);
}
}
isACenterNode[centerNode] = 1;
}
printf("%d\n", groupCount);
for (int i = 1; i <= n; i++) {
if (isACenterNode[i]) {
printf("%d\n", i);
}
}
return 0;
}