// Arup Guha
// 2/11/2014
// Solution to 2009 UCF Locals Problem: Team Assignment

import java.util.*;

public class assign {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int e = stdin.nextInt();

		// Go through each case.
		while (n != 0) {

			ArrayList[] eList = new ArrayList[n];
			for (int i=0; i<n; i++) eList[i] = new ArrayList<Integer>();

			// Read in edges.
			for (int i=0; i<e; i++) {
				int v1 = stdin.nextInt() - 1;
				int v2 = stdin.nextInt() - 1;
				eList[v1].add(v2);
				eList[v2].add(v1);
			}

			// Everyone is on team 1 at first. =)
			boolean[] team = new boolean[n];
			Arrays.fill(team, true);
			boolean side = true;

			// Greedy iterative algorithm, moving people from one side to the other.
			while (iterate(team, side, eList))
				side = !side;

			// Make true the larger team.
			int ans = count(team);
			if (ans < n/2) {
				reverse(team);
				ans = n - ans;
			}

			// Print our team.
			System.out.println(ans);
			for (int i=0; i<n; i++)
				if (team[i])
					System.out.print((i+1)+" ");
			System.out.println("\n");

			// Go to next case.
			n = stdin.nextInt();
			e = stdin.nextInt();
		}
	}

	// Returns the number of people on team true.
	public static int count(boolean[] team) {
		int cnt = 0;
		for (int i=0; i<team.length; i++)
			if (team[i])
				cnt++;
		return cnt;
	}

	// Swaps the two teams.
	public static void reverse(boolean[] team) {
		for (int i=0; i<team.length; i++)
			team[i] = !team[i];
	}

	public static boolean iterate(boolean[] team, boolean side, ArrayList[] eList) {

		boolean flag = false;

		// Go through each item.
		for (int i=0; i<team.length; i++) {

			// Only look at the team side.
			if (team[i] == side) {

				// Count rivals on same team.
				int cnt = 0;
				for (int j=0; j<eList[i].size(); j++)
					if (team[(Integer)eList[i].get(j)] == side)
						cnt++;

				// We'll move this guy.
				if (cnt > 1) {
					team[i] = !side;
					flag = true;
				}
			}
		}

		// Note if we had to change anyone.
		return flag;
	}
}