use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::iter::FromIterator;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let m = scan.read::<usize>();
    let mut g = vec![vec![];n];
    for _ in 0..n + m - 1 {
        let a = scan.read::<usize>()-1;
        let b = scan.read::<usize>()-1;
        g[a].push(b);
    }
    let mut dag = Dag::new(&g);
    dag.tsort();
    let mut parent = vec![0;n];
    for &p in &dag.vs {
        for &v in &g[p] {
            parent[v] = p + 1;
        }
    }
    for i in 0..n {
        println!("{}", parent[i]);
    }
}

struct Dag {
    g: Vec<Vec<usize>>,
    vs: Vec<usize>,
    n: usize
}

#[allow(dead_code)]
impl Dag {
    fn new(g: &Vec<Vec<usize>>) -> Dag {
        let n = g.len();
        Dag {n: n, g: g.clone(), vs: vec![]}
    }

    fn tsort(&mut self) {
        let mut h = vec![0usize;self.n];
        for i in 0..self.n {
            for &v in &self.g[i] {h[v] += 1;}
        }
        let mut stack = vec![];
        for i in 0..self.n {if h[i] == 0 {stack.push(i);}}
        while let Some(i) = stack.pop() {
            self.vs.push(i);
            for &j in &self.g[i] {
                h[j] -= 1;
                if h[j] == 0 {stack.push(j);}
            }
        }
    }

    fn is_acyclic(&self) -> bool {
        self.vs.len() == self.n
    }

    fn is_unique(&self) -> bool {
        for i in 0..self.n - 1 {
            let a = self.vs[i];
            let b = self.vs[i+1];
            let mut f = false;
            for &v in &self.g[a] {
                if v == b {
                    f = true;
                    break;
                }
            }
            if !f {return false;}
        }
        true
    }

    fn longest_path(&self) -> usize {
        let mut dp = vec![0;self.n];
        for &p in &self.vs {
            for &v in &self.g[p] {
                dp[v] = std::cmp::max(dp[v], dp[p] + 1);
            }
        }
        dp.into_iter().max().unwrap()
    }
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

#[allow(dead_code)]
fn alt<S, T>(v: Vec<S>) -> T where T: FromIterator<S> {
    v.into_iter().collect::<T>()
}

#[allow(dead_code)]
fn dup<S, T>(v: &[S]) -> T where T: FromIterator<S>, S: Clone {
    v.iter().cloned().collect::<T>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 21244