function main(input){
  var line0 = input[0].split(' ');
  var n = parseInt(line0[0]);
  var m = parseInt(line0[1]);
  
  var e = {};
  for (var i = 0; i< n-1+m; i++){
    var line = input[i+1].split(' ');

    var e1 = {from: parseInt(line[0]), to: parseInt(line[1])};
    if (!e[e1.to]) e[e1.to] = [];
    e[e1.to].push(e1);
  }

  var ans = [];
  for (var i =1; i<= n; i++) {
    if (!e[i]) e[i] = [];
  }
  for (var i =1; i<= n; i++) {
    if (e[i].length > 1) {
      var parents = [];
      for(var j = 0; j < e[i].length; j++) {
        parents.push({l: findParent(e[i][j].from, e).length, e: e[i][j]});
      }
      parents.sort((a,b) => b.l - a.l);
      ans[i-1] = parents[0].e.from;
    } else {
      ans[i-1] = e[i].length? e[i][0].from : 0;
    }
  }
  console.log(ans.join('\n'));
}

function findParent(node, e) {
  var q = [];
  var ans = [node];
  for (var i=0; i<e[node].length; i++){
    q.push(e[node][i]);
  }
  while(q.length) {
    var first = q.shift();
    ans.unshift(first.from);
    if (e[first.from]) {
      for (var i=0; i<e[first.from].length; i++){
        q.push(e[first.from][i]);
      }
    }
  }
  return ans;
}

var input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});
