w = gets.to_i
n = gets.to_i
arr = []
n.times{|i|
    a, b = gets.chomp.split(",").map(&:to_i)
    arr << [a, b, i]
    arr << [b, a, i]
}

result = []
1.upto(w){|x|
    b = x
    index = -1
    arr.each{|s, g, i|
        if s == b && i > index
            b = g
            index = i
        end
    }
    result[b - 1] = x
 }
puts result
