n = gets.to_i
a, d = gets.chomp.split.map(&:to_i)
h = Hash.new{|h, k| h[k] = k}
gets.to_i.times{
    x, y, z = gets.chomp.split.map(&:to_i)
    case x
    when 0
        temp = h[y]
        h[y] = h[z]
        h[z] = temp
    when 1
        h[y] = h[z]
    end
}
puts a + d * (h[gets.to_i] - 1)
