#include<bits/stdc++.h>
using namespace std;
vector<int> ga[100010];
int indeg[100010];
int a,b;
int ancest[100010];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=(n-1+m);i++){
		cin>>a>>b;
		ga[a].push_back(b);
		indeg[b]++;
	}
	stack<int> S;
	for(int i=1;i<=n;i++)
	   if(indeg[i]==0){
	   	  S.push(i);
	   	  ancest[i]=0;
	   }
	while(!S.empty()){
		int curr=S.top();
		S.pop();
		for(int i=0;i<ga[curr].size();i++)
		{
			indeg[ga[curr][i]]--;
			if(indeg[ga[curr][i]]==0){
				S.push(ga[curr][i]);
				ancest[ga[curr][i]]=curr;
			}
		}
	}
	for(int i=1;i<=n;i++)
	   cout<<ancest[i]<<endl;
}