#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>

using namespace std; 

int main() {
	freopen("where.in", "r", stdin);
	freopen("where.out", "w", stdout);
	int n, m, x, y;
	long long k;
	cin >> n >> m >> k;
	vector <int> edge[100031];
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &x, &y);
		edge[x].push_back(y);
		edge[y].push_back(x);
	}     
	queue < pair<int, int> > que;

	pair<int, int> t;
	t.first = 1;
	t.second = 0;
	que.push(t);
	int d[200031];
	for (int i = 1; i <= 2 * n; i++) {
		d[i] = -1;
	}
	long long vv;
	int v = 0, u = 0;
	d[1] = 0;
 	while (!que.empty()) {       	
		v = que.front().first;
		if (v > n) v = v - n;
		vv = que.front().second;
		//cout << v << " ";
		que.pop();
		if (vv == k) continue;
		for (int i = 0; i < edge[v].size(); i++) {
			u = edge[v][i];
			if (vv % 2 == 0) u = n + u;
			if (d[u] == -1) {
				d[u] = vv + 1;
				t.first = u;
				t.second = vv + 1;
				que.push(t);
			}
		}
	}
	int kol = 0;
	if (k % 2 == 0) {
		for (int i = 1; i <= n; i++) {
			if (d[i] != -1) kol++;
		} 
	} else {
		for (int i = n + 1; i <= 2 * n; i++) {
			if (d[i] != -1) kol++;
		}
	}
	cout << kol << endl;
	if (k % 2 == 0) {
		for (int i = 1; i <= n; i++) {
			if (d[i] != -1) {
				cout << i << " ";
			}
		}
	} else  {
		for (int i = n + 1; i <= 2 * n; i++) {
			if (d[i] != -1) {
				cout << i - n << " ";
			}
		}
	}
	return 0;
} 
