#include <stdio.h>
#include <vector>
#include <bitset>
using namespace std;
const int N=1e5+10;
#define PB push_back
int a[N],p[N];
vector<int> graph[N];
bitset<N> went;
void dfs(int now){
    went[now]=true;
    for(int i:graph[now])if(!went[i]){
        if(a[i]>1)a[i]--;
        else p[i]=now;
    }
    for(int i:graph[now])if(p[i]==now)dfs(i);
    return ;
}
int main(){
    int n,m,l,r;
    scanf("%d%d",&n,&m);
    went.reset();
    for(int i=1;i<=n;i++)a[i]=0;
    m+=n-1;
    while(m--){
        scanf("%d%d",&l,&r);
        graph[l].PB(r);
        a[r]++;
    }
    for(int i=1;i<=n;i++)if(a[i]==0){
        p[i]=0;
        dfs(i);
        break;
    }
    for(int i=1;i<=n;i++)printf("%d\n",p[i]);
}