拓扑排序
var a:array[1..100,1..100]of longint;
b,f:array[1..100]of longint;
i,j,k,n,m,x,y:longint;
begin
readln(n,m);
for i:=1 to m do
begin
readln(x,y);
a[x,y]:=1;
f[y]:=f[y]+1;
end;
i:=0;
while i<n do
begin
j:=1;
while f[j]<>0 do
j:=j+1;
f[j]:=f[j]-1;
for k:=1 to n do
if a[j,k]=1 then
begin
f[k]:=f[k]-1;
a[j,k]:=0;
end;
i:=i+1;
b[i]:=j;
end;
for i:=1 to n do
writeln(b[i]);
end.
var a:array[1..100,1..100]of longint;
b,f:array[1..100]of longint;
i,j,k,n,m,x,y:longint;
begin
readln(n,m);
for i:=1 to m do
begin
readln(x,y);
a[x,y]:=1;
f[y]:=f[y]+1;
end;
i:=0;
while i<n do
begin
j:=1;
while f[j]<>0 do
j:=j+1;
f[j]:=f[j]-1;
for k:=1 to n do
if a[j,k]=1 then
begin
f[k]:=f[k]-1;
a[j,k]:=0;
end;
i:=i+1;
b[i]:=j;
end;
for i:=1 to n do
writeln(b[i]);
end.