#include <bits/stdc++.h>
using namespace std;

const int N = 100005;

int n, m;
vector <int> g[N];
int par[N];
int in[N];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> m;
	for (int i = 1; i <= n + m - 1; ++i) {
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		++in[v];
	}
	
	int root = 0;
	for (int i = 1; i <= n; ++i) if (!in[i]) root = i;
	
	queue <int> q;
	q.push(root);
	
	while(!q.empty()) {
		int u = q.front(); q.pop();
		for (int &v : g[u]) {
			if (--in[v] == 0) q.push(v), par[v] = u;
		}
	}
	
	for (int i = 1; i <= n; ++i) printf("%d\n", par[i]);
}
