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] ~= a;
		v2[a] ~= b;
	}

	auto index = new ulong[](N);
	makeIndex!"a.length < b.length"(v, index);

	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);
		}
	}
	computeRank(index[0], 0);

	auto index2 = new ulong[](N);
	makeIndex(rank, index2);

	bool hasRoot = v[index[0]].length == 0;
	foreach (ii, i; index2)
	{
		if (!hasRoot)
		{
			v[i].length = 0;
			hasRoot = true;
		}
		else if (v[i].length > 1)
		{
			long bestI, bestR = -1;
			foreach (e; v[i])
			{
				if (cast(long)rank[e] > bestR)
				{
					bestR = rank[e];
					bestI = e;
				}
			}
			v[i].length = 1;
			v[i][0] = bestI;
		}
	}

	foreach (e; v) writeln(e.length == 0 ? 0 : e[0] + 1);
	stdout.flush();
}