#include<bits/stdc++.h>

using namespace std;

const int N = 100005;

vector<int> g[N];
int in[N], parent[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m + (n - 1); i++) {
    int u, v;
    cin >> u >> v;
    in[v]++;
    g[u].push_back(v);
  }
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (in[i] == 0) {
      q.push(i);
      break;
    }
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (auto v : g[u]) {
      in[v]--;
      if (in[v] == 0) {
        q.push(v);
        parent[v] = u;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << parent[i] << '\n';
  }
  return 0;
}
