#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

ll N, M;
vector<ll> E[100000], R[100000];
ll parent[100000];
bool path[100000];

void dfs(ll v, ll p) {
  for (ll u : R[v]) if (!path[u]) return;

  parent[v] = p;
  path[v] = true;

  for (ll u : E[v]) dfs(u, v);

  path[v] = false;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N + M - 1) {
    ll A, B;
    cin >> A >> B, A--, B--;
    E[A].push_back(B);
    R[B].push_back(A);
  }

  ll root;
  REP(i, 0, N) if (R[i].size() == 0) root = i;

  dfs(root, -1);

  REP(i, 0, N) cout << parent[i] + 1 << endl;
}