#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	vector<int> h(n);
	for (int i = 0; i < n + m - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		h[y]++;
	}
	vector<int> ans(n);
	queue<int> que;
	for (int i = 0; i < n; i++) {
		if (h[i] == 0) que.push(i);
	}
	ans[que.front()] = -1;
	while ((int) que.size()) {
		int from = que.front();
		que.pop();
		for (auto &to : g[from]) {
			h[to]--;
			if (h[to] == 0) {
				que.push(to);
				ans[to] = from;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] + 1 << '\n';
	} 
	return 0;
}