#include<iostream>
using namespace std;
#include<string>
#include<fstream>
#include<algorithm>
#include<queue>
#include<vector>
vector< vector<int> >g(128);
queue<int>q;
bool visited[128];
vector<int>path;
void bfs() {
	if (q.empty())return;
	int k = q.front();
	q.pop();
	path.push_back(k);
	visited[k] = true;
	for (int i = 0; i < g[k].size();i++) {
		if (!visited[g[k][i]]) {
			q.push(g[k][i]);
			visited[g[k][i]] = true;
		}
	}
	//出队一个元素,对队头元素递归bfs
	bfs();
}
int main() {
	ifstream ifs("graph.in");
	
	int n; ifs >> n;
	int a, b;
	while (ifs >> a >> b) {
		g[a].push_back(b);
		g[b].push_back(a);
	}
	for (int i = 0; i <= n; i++)visited[i] = false;
	//开始遍历
	q.push(1); visited[1] = true;
	bfs();
	//output
	for (int i = 0; i < path.size(); i++)
		cout << path[i] << " ";
	cout << endl;
	return 0;
}