// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define putchar putchar_unlocked

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char ci[cm];

char *cn = ci + cm;

inline char getcha() {

	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }

	return *cn++;

}



inline int getint() {

	char C = getcha();

	int A = C - '0';

	while ((C = getcha()) >= '0') A = A * 10 + C - '0';

	return A;

}



inline void putint(int X) {

	if (X == 0) putchar('0');

	int keta = 0;

	char C[10];

	while (X) {

		C[keta] = '0' + X % 10;

		X /= 10;

		keta++;

	}

	for (int i = keta - 1; i >= 0; i--) putchar(C[i]);

	putchar('\n');

}



int oya;

int D[100001];

int P[100001];

vector<int> V[100001];

int sagasu(int A) {

	if (*(D + A)) return *(D + A);

	if (A == oya) return 1;

	int ret = 0;

	for (int i : *(V + A)) {

		int kari = sagasu(i) + 1;

		if (ret < kari) {

			ret = kari;

			*(P + A) = i;

		}

	}

	*(D + A) = ret;

	return ret;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N, M;

	N = getint();

	M = getint();

	bool kodomo[100001] = {};

	rep(i, N + M - 1) {

		int a, b;

		a = getint();

		b = getint();

		V[b].pb(a);

		kodomo[b] = true;

	}



	rep1(i, N) {

		if (!kodomo[i]) {

			oya = i;

			break;

		}

	}



	rep1(i, N) {

		sagasu(i);

		putint(P[i]);

	}



	Would you please return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.3127431350579446x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define putchar putchar_unlocked

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



const int cm = 1 << 17;

char ci[cm];

char *cn = ci + cm;

inline char getcha() {

	if (cn - ci == cm) { fread(ci, 1, cm, stdin); cn = ci; }

	return *cn++;

}



inline int getint() {

	char C = getcha();

	int A = C - '0';

	while ((C = getcha()) >= '0') A = A * 10 + C - '0';

	return A;

}



inline void putint(int X) {

	if (X == 0) putchar('0');

	int keta = 0;

	char C[10];

	while (X) {

		*(C + keta) = '0' + X % 10;

		X /= 10;

		keta++;

	}

	for (int i = keta - 1; i >= 0; i--) putchar(*(C + i));

	putchar('\n');

}



int oya;

int D[100001];

int P[100001];

pair<int, int> E[100001];

int EN[100002];

int sagasu(int A) {

	if (*(D + A)) return *(D + A);

	if (A == oya) return 1;

	for (int i = (*(EN + A)); i < (*(EN + A + 1)); i++) {

		int j = (*(E + i)).second;

		int kari = sagasu(j) + 1;

		if (*(D + A) < kari) {

			*(D + A) = kari;

			*(P + A) = j;

		}

	}

	return *(D + A);

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N, M;

	N = getint();

	M = getint();

	bool kodomo[100001] = {};

	rep(i, N + M - 1) {

		int a, b;

		a = getint();

		b = getint();

		E[i] = mp(b, a);

		kodomo[b] = true;

	}



	rep1(i, N) {

		if (!kodomo[i]) {

			oya = i;

			break;

		}

	}



	sort(E, E + N + M - 1);

	int k = 0;

	int mae = 0;

	EN[1] = 0;

	rep1(i, N) {

		while (k < N + M - 1 && E[k].first == i) k++;

		EN[i + 1] = k;

		mae = k;

	}



	rep1(i, N) {

		if (!(*(D + i))) sagasu(i);

		putint(*(P + i));

	}



	Would you please return 0;

}