#include <iostream> using namespace std; #include <string> int main() { freopen("in.txt","r",stdin); int n; int temp; int c[200]; int a[200][200]; int degree[200]; for (int i=0;i<200;i++) { c[i]=0; degree[i]=0; } cin>>n; for (int i=1;i<=n;i++) { cin>>temp; while (temp!=0) { a[i][++c[i]]=temp; degree[temp]++; cin>>temp; } } for (int i=1;i<=n;i++) { for (int j=1;j<=n;j++) { if (degree[j]==0) { cout<<j; degree[j]=123456789; for (int k=1;k<=c[j];k++) { degree[a[j][k]]--; } break; } } if (i<n) { cout<<" "; } else { cout<<endl; } } return 0; }