v, e = gets.chomp.split.map(&:to_i)
exit if e == 0
item = []
e.times do
  item << gets.chomp.split.map(&:to_i)
end

g = Array.new(v)
item.each do |elem|
  s = elem[0]
  t = elem[1]
  g[s] ||= []
  g[t] ||= []
  g[s] << t
  g[t] << s
end

$g = g.map(&:uniq)

$prenum = Array.new(v)
$parent = Array.new(v) 
$lowest = Array.new(v)


$cnt = 0
def dfs(idx, prev)
  $prenum[idx] = $lowest[idx] = $cnt
  $cnt += 1
  


  $g[idx].each do |item|
    unless $prenum[item].nil?
      unless item == prev
        $lowest[idx] = [$lowest[idx], $prenum[item]].min
      end
      next
    end

    $parent[item] = idx
    dfs(item, idx)
    $lowest[idx] = [$lowest[idx], $lowest[item]].min
  end
end

dfs(0, 1)

res = Array.new(v, false)

res[0] = true if $parent.count{|i| i == 0} > 1



(1...v).each do |u|
  p = $parent[u]
  res[p] = true if p != 0 and $prenum[p] <= $lowest[u]
end

puts res.each.with_index.select{|i, idx| i }.map{|i| i[1]}.join("\n") unless res.empty?