w = gets.chomp.to_i
n = gets.chomp.to_i

table = Hash.new
w.times do |i|
  table[i] = Hash.new
end

n.times do |n|
  a, b = gets.chomp.split(",").map{|i| i.to_i - 1}
  table[a][n] = b
  table[b][n] = a
end

result = Array.new
w.times do |base|
  current = base
  n.times do |i|
    current = table[current][i] unless table[current][i].nil?
  end
  result[current] = base + 1
end

puts result