#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+10;
int n,m,inde[N],ans[N],x,y; 
vector<int>E[N];
queue<int> q;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n+m-1;i++)
	{
		cin>>x>>y;
		x--,y--;
		E[x].push_back(y);
		inde[y]++; 
	} 
	queue<int>q;
	for(int i=0;i<n;i++) if(!inde[i]) ans[i+1]=0,q.push(i);
	while(!q.empty())
	{
		int u=q.front();
		q.pop();
		for(int i=0;i<E[u].size();i++)
		{
			int uu=E[u][i];
			inde[uu]--;
			if(!inde[uu]) ans[uu+1]=u+1,q.push(uu);
		}
	}
	for (int i=1;i<=n;i++) cout<<ans[i]<<endl;
	return 0;
}