#include <bits/stdc++.h>
using namespace std;
vector<int> e[10005];
queue<int> q;
int in[10005], n;
int main()
{
cin >> n;
for(int i = 1; i <= n; i++)
{
int a;
while (cin >> a && a != 0)
{
e[i].push_back(a);
in[a]++;
}
}
for(int i = 1; i <= n; i++)
if(in[i] == 0)
q.push(i);
while(!q.empty())
{
int x = q.front();
q.pop();
cout << x << " ";
for(int i = 0; i <= e[x].size() - 1; i++)
{
in[e[x][i]]--;
if(in[e[x][i]] == 0)
q.push(e[x][i]);
}
}
return 0;
}