#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i, MAT.size()){
    REP(j, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

class TS_DFS{
  private:
    // # of vertecis
    ll v;
    vector<vector<ll>> g;
    vector<bool> used;

    void dfs(int u){
      if(used[u]) return;
      used[u] = true;
      for(auto& i : g[u]) dfs(i);
      //add when back
      ans.push_back(u);
      return;
    };

  public:
    //answer
    vector<ll> ans;

    TS_DFS(ll v){
      this->v = v;
      vector<ll> zero(0);
      g.resize(v, zero);
      used.resize(v, false);
    };

    ~TS_DFS(void){
      return;
    };

    void add_edge(ll start, ll end){
      g[start].push_back(end);
      return;
    };

    void tsort(void){
      for(ll i=0; i<v; ++i) dfs(i);
      reverse(ans.begin(), ans.end());
      return;
    };
};

class NUM_OF_IN{
  private:
    ll v, e;
    vvll g;
    vll h;
  public:
    //answer
    vll ans;

    NUM_OF_IN(ll v){
      this->v = v;
      vll zero(0);
      g.resize(v, zero);
      h.resize(v, 0);
      return;
    };

    void add_edge(ll start, ll end){
      g[start].push_back(end);
      h[end]++;
      return;
    };

    void tsort(void){
      stack<ll> st;
      REP(i, v) if(h[i]==0) st.push(i);
      while(st.size()){
        ll i = st.top(); st.pop();
        ans.push_back(i);
        for(auto& j: g[i]){
          h[j]--;
          if(h[j]==0) st.push(j);
        }
      }
      return;
    };
};



int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, M;
  cin >> N >> M;
  TS_DFS ts(N);
  //NUM_OF_IN noi(N);
  vvll reverse_edge(N);

  REP(i, N+M-1){
    ll start, end;
    cin >> start >> end;
    start--; end--;
    ts.add_edge(start, end);
    //noi.add_edge(start, end);
    reverse_edge[end].push_back(start);
  }

  ts.tsort();
  //noi.tsort();

  /*
  REP(i, N){
    cout << ts.ans[i] << " " << noi.ans[i] << "\n";
  }
  */

  vll ans_rev(N);
  REP(i, N){
    ans_rev[ts.ans[i]] = i;
  }

  REP(i, N){
    ll ans = -1;
    ll pos = -1;
    REP(j, reverse_edge[i].size()){
      if(pos < ans_rev[reverse_edge[i][j]]){
        ans = reverse_edge[i][j];
        pos = ans_rev[ans];
      }
    }
    cout << ans+1 << "\n";
  }

  return 0;
}

Measured memory_bytes: 15480