voidtopsort(){ priority_queue<int> s; for(int i = 1; i <= n; ++i) if(in[i] == 0) s.push(i);
int cnt = n; while(!s.empty()) { int u = s.top(); s.pop(); L[cnt--] = u; for(int i = 0; i < G[u].size(); ++i) { int v = G[u][i]; if(--in[v] == 0) s.push(v); } } }
voidsolve(){ for(int i = 1; i <= n; ++i) G[i].clear(); memset(in, 0, sizeof(in)); cin >> n >> m;
for(int i = 1, x, y; i <= m; ++i) { cin >> x >> y; ++in[x]; G[y].push_back(x); }
topsort(); for(int i = 1; i <= n; ++i) cout << L[i] << ' '; cout << '\n'; }