x=gets.to_i gets $<.map{|s|p,q=s.split.map &:to_i;x==p&&x=q} p x