// 拓扑排序 kahn算法
#include <bits/stdc++.h>
using namespace std;
int n, a;
vector<int> e[105];
int d[105];
void tpkahn()
{
// 所有度0点入队
queue<int> q;
for (int i = 1; i <= n; i++)
if (!d[i])
q.push(i);
while (!q.empty())
{
int u = q.front();
q.pop();
cout << u << " ";
for (int i = 0; i < e[u].size(); i++)
{
int v = e[u][i];
d[v]--;
if (!d[v])
q.push(v);
}
}
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
while (cin >> a)
{
if (!a)
break;
e[i].push_back(a);
d[a]++;
}
}
tpkahn();
return 0;
}