Problem:
Score : 500 points

Problem Statement

You are given a connected undirected simple graph, which has N vertices and M edges.
The vertices are numbered 1 through N, and the edges are numbered 1 through M.
Edge i connects vertices A_i and B_i.
Your task is to find a path that satisfies the following conditions:

The path traverses two or more vertices.

The path does not traverse the same vertex more than once.

A vertex directly connected to at least one of the endpoints of the path, is always contained in the path.

It can be proved that such a path always exists.
Also, if there are more than one solution, any of them will be accepted.

Constraints

2 \leq N \leq 10^5

1 \leq M \leq 10^5

1 \leq A_i < B_i \leq N

The given graph is connected and simple (that is, for every pair of vertices, there is at most one edge that directly connects them).

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
A_2 B_2
:
A_M B_M

Output

Find one path that satisfies the conditions, and print it in the following format.
In the first line, print the count of the vertices contained in the path.
In the second line, print a space-separated list of the indices of the vertices, in order of appearance in the path.

Sample Input 1

5 6
1 3
1 4
2 3
1 5
3 5
2 4

Sample Output 1

4
2 3 1 4

There are two vertices directly connected to vertex 2: vertices 3 and 4.
There are also two vertices directly connected to vertex 4: vertices 1 and 2.
Hence, the path 2 → 3 → 1 → 4 satisfies the conditions.

Sample Input 2

7 8
1 2
2 3
3 4
4 5
5 6
6 7
3 5
2 6

Sample Output 2

7
1 2 3 4 5 6 7

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<stdio.h>
#include<stdlib.h>
#include<string.h>


typedef struct tag_vertex_t
{
	int id, is_passed;
	int edge_num, *edge;
}vertex_t;


#define N_MAX 100000
#define M_MAX 100000

int n, m;
vertex_t vertex[N_MAX+1];
int result[N_MAX];
int result_num;


void result_init(void)
{
	result_num=0;
}


void result_push_back(int x)
{
	result[result_num++]=x;
}


void result_push_front(int x)
{
	memmove(result+1, result, sizeof(result[0])*result_num);
	result[0]=x;
	result_num++;
}


int result_pop_back(void)
{
	if(result_num<=0) return -1;
	return result[--result_num];
}


void edge_add(vertex_t *vert, int to)
{
	vert->edge=realloc(vert->edge, sizeof(int)*(vert->edge_num+1));
	vert->edge[vert->edge_num++]=to;
}


void vertex_zero(vertex_t *vert)
{
	vert->id=0;
	vert->is_passed=0;
	vert->edge_num=0;
	free(vert->edge);
	vert->edge=NULL;
}


int main(void)
{
	int a, b, i, c=0, s, e;

	while(scanf("%d%d", &n, &m)==2)
	{
		result_init();
		for(i=0;i<n;i++)
		{
			vertex_zero(&vertex[i]);
		}

		for(i=0;i<m;i++)
		{
			scanf("%d%d", &a, &b);
			edge_add(&vertex[a], b);
			edge_add(&vertex[b], a);
			c=a;
		}

		for(s=c;;)
		{
			result_push_front(s);
			vertex[s].is_passed=1;
			for(i=0;i<vertex[s].edge_num;i++)
			{
				if(vertex[vertex[s].edge[i]].is_passed) continue;
				break;
			}
			if(i>=vertex[s].edge_num) break;
			s=vertex[s].edge[i];
		}

		result_pop_back();
		for(e=c;;)
		{
			result_push_back(e);
			vertex[e].is_passed=1;
			for(i=0;i<vertex[e].edge_num;i++)
			{
				if(vertex[vertex[e].edge[i]].is_passed) continue;
				break;
			}
			if(i>=vertex[e].edge_num) break;
			e=vertex[e].edge[i];
		}

		printf("%d", result[0]);
		for(i=1;i<result_num;i++) printf(" %d", result[i]);
		printf("\n");
	}

	return 0;
}