#include<bits/stdc++.h>
#define N 500005
using namespace std;
int n,m,x,y,kk,q[N],fa[N],ru[N],head[N];
struct node{int nxt,to;}e[N];
inline void link(int x,int y){e[++kk].nxt=head[x];e[kk].to=y;head[x]=kk;}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<n+m;i++){
		scanf("%d%d",&x,&y);
		link(x,y);ru[y]++;
	}
	int left1=1,right1=1;
	for (int i=1;i<=n;i++) if (!ru[i]) q[1]=i;
	while (left1<=right1){
		int u=q[left1++];
		for (int i=head[u];i;i=e[i].nxt){
			int v=e[i].to;
			if (ru[v]==1){fa[v]=u;q[++right1]=v;}
			ru[v]--;
		}
	}
	for (int i=1;i<=n;i++) printf("%d\n",fa[i]);
	return 0;
}