#include <bits/stdc++.h>

using namespace std;

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL); cout.tie(NULL);

  int n, m;
  cin >> n >> m;
  vector < int > deg(n, 0);
  vector < vector < int > > g(n);
	
  m += n - 1;

  while(m--) {
    int u, v;
    cin >> u >> v;
    --u; --v;
    g[u].push_back(v);
    ++deg[v];
  }

  vector < int > qu;
  vector < int > ans(n);

  for(int v = 0; v < n; ++v) {
    if(deg[v] == 0) {
      ans[v] = -1;
      qu.emplace_back(v);
    }
  }

  for(int it = 0; it < n; ++it) {
    int v = qu.back();
    qu.pop_back();

    for(int s : g[v]) {
      ans[s] = v;
      if(--deg[s] == 0) {
        qu.push_back(s);
      }
    }
  }

  for(auto x : ans) cout << ++x << endl;

  return 0;
}