#include <cstdio>
#include <vector>
#include <tuple>

using namespace std;

vector<int> parents[100024];
int result[100024] = {0};
int answer[100024] = {0};

int func(int child) {
	if(answer[child]) {
		return answer[child];
	}
	int r = 0;
	int ans = 1;
	for(int p : parents[child]) {
		int a = func(p) + 1;
		if(ans<a) {
			ans = a;
			r = p + 1;
		}
	}
	result[child] = r;
	answer[child] = ans;
	return answer[child];
}

int main() {
	int N, M;
	scanf("%d%d", &N, &M);
	for(int i=0; i<N+M-1; ++i) {
		int parent, child;
		scanf("%d%d", &parent, &child);
		parents[child-1].emplace_back(parent-1);
	}
	for(int i=0; i<N; ++i) {
		func(i);
		printf("%d\n", result[i]);
	}

	return 0;
}
