#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int N,M,p[100010] = {},c[100010] = {},cnt[100010] = {};
vector<vector<int>> v(100010);
int main(){
	cin >> N >> M;
	int a,b;
	for(int i=0;i<N+M-1;i++){
		cin >> a >> b;
		v[a].push_back(b);
		c[b]++;
	}
	int id = 0;
	for(int i=1;i<=N;i++){
		if(c[i]==0){
			p[i] = 0;
			id = i;
			break;
		}
	}
	queue<int> Q;
	Q.push(id);
	while(!Q.empty()){
		int s = Q.front(); Q.pop();
		for(int i=0;i<v[s].size();i++){
			int t = v[s][i];
			cnt[t]++;
			if(cnt[t]==c[t]){
				p[t] = s;
				Q.push(t);
			}
		}
	}
	for(int i=1;i<=N;i++) cout << p[i] << endl;
}