#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int deg[100010];
vector<int>G[100010];
int n,m;
int fa[100010];
bool vis[100010];
void dfs(int x,int pr){
	vis[x]=1;
	fa[x]=pr;
	for(auto to:G[x])deg[to]--;
	for(auto to:G[x])if(!vis[to]&&deg[to]==0)dfs(to,x);
}
int root;
int main(){
	cin>>n>>m;
	for(int i=1,x,y;i<=m-1+n;i++){
		cin>>x>>y;
		G[x].pb(y);
		deg[y]++;
	}
	for(int i=1;i<=n;i++)if(!deg[i]){
		root=i;
		break;
	}
	dfs(root,0);
	for(int i=1;i<=n;i++)cout<<fa[i]<<endl;
	return 0;
}