import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container;
import std.numeric, std.math;
import core.bitop;

string my_readln() { return chomp(readln()); }

long mod = pow(10, 9) + 7;
long moda(long x, long y) { return (x + y) % mod; }
long mods(long x, long y) { return ((x + mod) - (y % mod)) % mod; }
long modm(long x, long y) { return (x * y) % mod; }

void main()
{
	auto tokens = my_readln.split;
	auto N = tokens[0].to!long;
	auto M = tokens[1].to!long;
	auto v = new long[](N);
	auto v2 = new long[][](N);
	foreach (i; 0..N-1+M)
	{
		auto tokens2 = my_readln.split;
		auto a = tokens2[0].to!long - 1;
		auto b = tokens2[1].to!long - 1;
		v[b] = 1;
		v2[a] ~= b;
	}
	auto rank = new ulong[](N);

	void computeRank(ulong i, ulong r)
	{
		rank[i] = max(rank[i], r);
		foreach (e; v2[i])
		{
			computeRank(e, r+1);
		}
	}
	ulong startPos;
	foreach (i; 0..N)
	{
		if (v[i] == 0)
		{
			startPos = i;
			break;
		}
	}
	computeRank(startPos, 0);

	auto ans = new long[](N);
	fill(ans, startPos);
	
	void f(ulong i, ulong p)
	{
		if (i != p)
			ans[i] = rank[ans[i]] <= rank[p] ? p : ans[i];
		else
			ans[i] = -1;
		foreach (e; v2[i])
		{
			f(e, i);
		}
	}
	f(startPos, startPos);

	foreach (e; ans) writeln(e + 1);
	stdout.flush();
}