w = gets.to_i
n = gets.to_i

a = []
b = []
n.times { |i|
	a[i], b[i] = gets.split(',').map(&:to_i)
}

r = []

w.times { |i|
	k = i + 1
	n.times{ |j|
		if a[j] == k then
			k = b[j]
		elsif b[j] == k then
			k = a[j]
		end
	}
	r[k-1] = i + 1
}

r.each{ |k| puts(k) }