n = gets.to_i
a, d = gets.split.map(&:to_i)
m = gets.to_i
ops = (1..m).map { gets.split.map(&:to_i) }
k = gets.to_i
until ops.empty?
    x, y, z = ops.pop
    if x == 0
        if y == k
            k = z
        elsif z == k
            k = y
        end
    else
        k = z if y == k
    end
end
p a + (k - 1) * d
