#include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

int n, m;
bool used[100010];
vector<vector<ll>> g;
set<PII> x;

struct UnionFind {
  vector<int> par, s;
  UnionFind(int n=100010) { init(n); }
  void init(int n) { 
    s.assign(n, 1); par.resize(n); 
    iota(par.begin(), par.end(), 0);
  }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};
UnionFind uf;

void dfs(ll v) {
  used[v] = true;
  for(auto to: g[v]) {
    if(uf.same(v, to)) {
      x.insert({v, to});
      continue;
    }
    dfs(to);
  }
}

vector<ll> tsort(vector<vector<ll>> g) {
  const int n = g.size();
  vector<ll> h(n, 0);
  REP(i, n) for(int j: g[i]) h[j]++;

  stack<int> st;
  REP(i, n) if(h[i] == 0) st.push(i);

  vector<ll> ans;
  while(st.size()) {
    int i = st.top(); st.pop();
    ans.push_back(i);
    for(auto& j: g[i]) {
      h[j]--;
      if(h[j] == 0) st.push(j);
    }
  }

  return ans;
}

signed main(void) 
{
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll n, m;
  cin >> n >> m;
  vector<PII> a(n+m-1);
  g.resize(n);
  vector<vector<ll>> g2(n);
  REP(i, n+m-1) {
    cin >> a[i].first >> a[i].second;
    a[i].first--, a[i].second--;
    g[a[i].first].push_back(a[i].second);
    g2[a[i].second].push_back(a[i].first);
  }

  auto x = tsort(g);
  vector<ll> y(n);
  REP(i, n) y[x[i]] = i;

  vector<ll> ans(n, -1);
  REP(i, n) {
    ll ma = -1, idx = -1;
    for(auto j: g2[i]) {
      if(ma < y[j]) {
        ma = y[j];
        idx = j;
      }
    }
    ans[i] = idx;
  }

  REP(i, n) cout << ans[i]+1 << endl;

  // REP(i, n) {
  //   if(!used[i]) dfs(i);
  // }

  // vector<ll> ans(n, -1);
  // REP(i, n+m-1) {
  //   if(x.find(a[i]) != x.end()) continue;
  //   ans[a[i].second] = a[i].first;
  // }

  // REP(i, n) cout << ans[i]+1 << endl;

  return 0;
}

Measured memory_bytes: 20984