#include <bits/stdc++.h>
using namespace std;
vector<int> degrees;
vector<int> fa;
map<int, vector<int>> mp;
int main() {
  int n, m;
  cin >> n >> m;
  degrees.resize(n + 1, 0);
  fa.resize(n + 1, 0);
  for (int i = 0; i < n + m - 1; i++) {
    int x, y;
    cin >> x >> y;
    mp[x].push_back(y);
    degrees[y]++;
  }
  queue<int> q;
  for (int i = 1; i <= n; i++) {
    if (degrees[i] == 0) {
      q.push(i);
      break;
    }
  }
  while (q.size()) {
    int top = q.front();
    q.pop();
    vector<int>& t = mp[top];
    for (int k : t) {
      degrees[k]--;
      if (degrees[k] == 0) {
        fa[k] = top;
        q.push(k);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << fa[i] << endl;
  }
  return 0;
}
