x1, y1, x2, y2 = gets.chomp.split.map(&:to_f)

a = y2 - y1
b = x2 - x1
a2 = a * a
b2 = b * b
p = y1 - a / b * x1

gets.to_i.times{
    x, y = gets.chomp.split.map(&:to_f)
    if a == 0
        puts "#{x} #{y1 + (y1 - y)}"
    elsif b == 0
        puts "#{x1 + (x1 - x)} #{y}"
    else
        q = y + b / a * x
        cx = a * b * (q - p) / (a2 + b2) 
        cy = (a2 * q + b2 * p) / (a2 + b2)
        puts "#{cx + (cx - x)} #{cy + (cy - y)}"
    end
}
