#include <vector>
#include <list>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <time.h>
#include <queue>
using namespace std;

template <class T>
class BAG
{
	public:
		void insert(const T& t){c.push_back(t);}
		T removefirst()
		{
			T t=*(c.begin());
			c.pop_front();
			return t;
		}
		void removelast(){c.pop_back();}
		int size(){return c.size();}
		bool empty(){return c.empty();}
	private:
		deque<T> c;
};

	vector<int> predicessors(0);
	vector<list<int> > sucessors(0);
	vector<int> s;
	int N;
	BAG<int> the_bag;

void recursive()
{ 

	int i,j,k;
	if(the_bag.empty())
	{for(i=0;i<N;i++)cout<<s[i]<<" ";cout<<endl;return;}

	j=the_bag.size();
	for(i=0;i<j;i++)
	{
		k=the_bag.removefirst();

		s.push_back(k);

		for(list<int>::iterator itr=sucessors[k-1].begin();
		itr!=sucessors[k-1].end();++itr)
		{
			if(--predicessors[*itr-1]==0)
			{
				the_bag.insert(*itr);
			}
		}
		recursive();

		for(itr=sucessors[k-1].begin();
		itr!=sucessors[k-1].end();++itr)
		{
			if(++predicessors[*itr-1]==1)
			{
				the_bag.removelast();
			}
		}
		s.pop_back();
		the_bag.insert(k);
	}
}




int main(int argc,char* argv[])
{
	ifstream in(argv[1]);
	int n;
	in>>n;
	int x,y;
	N=n;

	predicessors.resize(n);
	sucessors.resize(n);
	s.resize(n);
	s.clear();
	while (in >>x >>y)
	{
		predicessors[y-1]++;
		sucessors[x-1].push_back(y);
	}
	for(int i=0;i<n;++i)
	{
		if(predicessors[i]==0)
		{
			the_bag.insert(i+1);
		}
	}
	recursive();
	return 0;
}








