#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,m;
	cin>>n>>m;
	vector<int> in(n+1,0),out(n+1,0),p(n+1,-1);
	vector<vector<int>> g(n+1);
	for(int i=0;i<n-1+m;++i){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		++out[u],++in[v];
	}
	queue<int> Q;
	for(int i=1;i<=n;++i) if(in[i]==0) Q.push(i),p[i]=0;
	while(!Q.empty()){
		int u=Q.front();
		Q.pop();
		for(int v:g[u]) 
			if(p[v]==-1){
				--in[v];
				if(in[v]==0) Q.push(v),p[v]=u;
			}
	}
	for(int i=1;i<=n;++i) cout<<p[i]<<'\n';
}