class Point
        attr_accessor :pos,:def_pos
        def initialize(num)
                @def_pos=num
                @pos=num
        end

        def moveto(n)
                @pos=n
        end
end
w=gets.to_i
n=gets.to_i
points=[]

w.times{|i|
        points<<Point.new(i+1)
}
ways=[]
n.times{
        ways << gets.split(',').map(&:to_i)
}
ways.each{|way|
        a=way[0] ; b=way[1]
        pa = points.find_index{|p|p.pos==a}
        pb = points.find_index{|p|p.pos==b}
        points[pa].moveto(b)
        points[pb].moveto(a)

#       p points[points.find_index{|p|p.pos==1}].pos
}
points.sort!{|p1,p2|
        p1.pos<=>p2.pos
}