// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)

#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)

#define fi first

#define se second

long long mo = 1000000007;

typedef long long ll;

typedef long double ld;

typedef pair<int,int> Pii;

typedef pair<ll,ll> Pll;

typedef pair<ll,Pll> PlP;

template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }

template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

ld PI=3.14159265358979323846;



vector<ll> used(100010), tp;

vector<vector<ll>> G(100010), H(100010);

/*

void dfs(ll v){

    if(used[v]) return;

    used[v] = 1;

    for(auto& u:G[v]){

        dfs(u);

    }

    tp.push_back(v);

}*/



int main(){

    ll N,M;

    cin >> N >> M;

    vector<ll> rc(N),deg(N);

    ll a,b;

    rep(i,N-1+M){

        cin >> a >> b;

        a--;b--;

        rc[b]++;

        G[a].push_back(b); 

        deg[b]++;

        H[b].push_back(a);

    }

    ll root;

    rep(i,N){

        if(rc[i] == 0){

            root = i;

            break;

        }

    }

    queue<ll> que;

    //vector<ll> par(N,-1);

    vector<ll> tv, ids(N);

    tv.push_back(root);

    que.push(root);

    while(!que.empty()){

        ll v = que.front();

        que.pop();

        for(auto& u:G[v]){

            deg[u]--;

            if(deg[u] == 0){

                //par[u] = v;

                tv.push_back(u);

                que.push(u);

            }

        }

    }

    rep(i,N){

        ids[tv[i]] = i;

    }

    //PR(tv,N);

    rep(i,N){

        ll tmp_id = -1;

        ll tmp_v = -1;

        for(auto&v:H[i]){

            if(tmp_id < ids[v]){

                tmp_id = ids[v];

                tmp_v = v;

            }

            //cout << tmp_v+1 << endl;

        }

        cout << tmp_v+1 << endl;

    }

    /*dfs(root);

    vector<ll> v(N);

    rep(i,N){

        v[tp[i]] = i;

    }

    //PR(v,N);

    vector<ll> ans(N,-1);

    rep(i,N){

        for(auto& u:G[i]){

            if(v[i] > v[u]){

                //cout << u+ << endl;

                ans[i] = u;

                break;

            }

        }

    }

    rep(i,N){

        cout << ans[i]+1 << endl;

    }

    /*queue<ll> que;

    que.push(root);

    prev[root] = -1;

    used[root] = 1;*/

    /*

    while(!que.empty()){

        ll v = que.front();

        que.pop();

        for(auto& u:G[v]){

            if(used[u] != 0){

                G[prev[u]].erase(lower_bound(G[prev[u]].begin(),G[prev[u]].end(),u));

                prev[u] = v;

                que.push(u);

                continue;

            }

            used[u] = 1;

            prev[u] = v;

            que.push(u);

        }

    }*/

    /*rep(i,N){

        cout << prev[i]+1 << endl;

    }*/

}

// Faster C++ solution for the same problem (measured speedup: 7.295067646735435x):
#include <bits/stdc++.h>

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)

#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)

#define fi first

#define se second

long long mo = 1000000007;

typedef long long ll;

typedef long double ld;

typedef pair<int,int> Pii;

typedef pair<ll,ll> Pll;

typedef pair<ll,Pll> PlP;

template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }

template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

ld PI=3.14159265358979323846;



int main(){

    ll N, M;

    cin >> N >> M;

    vector<ll> A(N-1+M), B(N-1+M), niv(N), S;

    vector<vector<ll>> G(N), H(N);

    rep(i,N-1+M){

        cin >> A[i] >> B[i];

        A[i]--;B[i]--;

        G[A[i]].push_back(B[i]);

        H[B[i]].push_back(A[i]);

    }

    rep(i,N-1+M){

        niv[B[i]]++;

    }

    queue<ll> que;

    vector<ll> memo(N);

    rep(i,N){

        if(niv[i] == 0){

            que.push(i);

            S.push_back(i);

            memo[i] = 1;

        }

    }

    //PR(S,S.size());

    while(!que.empty()){

        ll v = que.front();

        que.pop();

        S.push_back(v);

        for(auto& u:G[v]){

            niv[u]--;

            if(niv[u] == 0){

                que.push(u);

            }

        }

    }

    //PR(S,N);

    vector<ll> note(N);

    rep(i,N){

        note[S[i]] = i;

    }

    vector<ll> ans(N);

    rep(i,N){

        ll Mv = -1;

        ll u = -1;

        for(auto& v:H[i]){

            if(Mv < note[v]){

                Mv = note[v];

                u = v;

            }

        }

        ans[i] = u+1;

    }

    rep(i,N){

        cout << ans[i] << endl;

    }

}