#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int v = 6; // number of vertices
vector <vector<int>> adjecancy(v + 1); // adjecncy list of the graph

void addEdge(int x,int y) //add edge to the graph
{
	adjecancy[x].push_back(y);
	//adjecancy[y].push_back(x);
}

vector <bool> visited(v + 1);
vector <pair<int, int>> departureSorted(v+1);
int t = 0;

void topSort(int v)
{
	visited[v] = true;

	for (int i : adjecancy[v])
	{
		if (!visited[i])
			topSort(i);
	}
	departureSorted[v] = { ++t, v };
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int n;
	cin >> n;
	int x, y;
	map <int, int> parent;
	while (n--)
	{
		cin >> x >> y;
		addEdge(x, y);
	}

	topSort(1);

	//display vectices in topological ordering 
	sort(departureSorted.begin(), departureSorted.end());
	for (int i = departureSorted.size()-1; i >= 1; i--)
		cout << departureSorted[i].second << " ";
	
}