#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e6 + 5;
vector<int> g[maxn];
int deg[maxn], fa[maxn];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n - 1 + m; ++i) {
        int x, y; scanf("%d%d", &x, &y);
        --x, --y;
        g[x].push_back(y);
        ++deg[y];
    }
    memset(fa, -1, sizeof(fa));
    queue<int> q;
    for (int i = 0; i < n; ++i) 
        if (deg[i] == 0) q.push(i);
    while (q.size()) {
        int x = q.front(); q.pop();
        for (int i = 0; i < (int)g[x].size(); ++i) {
            int u = g[x][i];
            if ((--deg[u]) == 0) {
                fa[u] = x;
                q.push(u);
            }
        }
    }
    for (int i = 0; i < n; ++i) printf("%d\n", fa[i] + 1);
}
