require 'matrix'
x1, y1, x2, y2 = gets.split.map &:to_i
u = Vector[x1, y1]
v = Vector[x2, y2]
n = gets.to_i
n.times {
    w = Vector[*gets.split.map(&:to_i)]
    a = v - u
    b = w - u
    x = u + a * a.inner_product(b) / a.r ** 2
    puts "#{x[0]} #{x[1]}"
}