import std.stdio, std.string, std.conv;
import std.algorithm, std.array;
auto solve(string s_) {
    auto NM = s_.split.map!(to!int)();
    immutable N=NM[0], M=NM[1];
    auto g = new int[][N+1];
    auto c = new int[N+1];
    foreach(_;0..N-1+M) {
        auto AB = readln.split.map!(to!int)();
        immutable A=AB[0], B=AB[1];
        g[A]~=B;
        c[B]++;
    }
    int[] e; e.reserve(N);
    int[] e2; e2.reserve(N);
    auto t = new int[N];
    foreach(i;1..N) if(c[i]==0) e~=i;
    while(e.length) {
        e2.length=0;
        foreach(u;e) foreach(v;g[u]) if(--c[v]==0) {
            e2~=v;
            t[v-1]=u;
        }
        swap(e,e2);
    }
    return t.map!(to!string).join("\n");
}
void main(){ for(string s; (s=readln.chomp()).length;) writeln(solve(s)); }