def projecter(x, y, xp, yp)
  return (xp * x + yp * y) / (x ** 2 + y ** 2)
end
def main(input = STDIN)
  x1, y1, x2, y2 = input.gets.split(" ").map(&:to_r)
  q = input.gets.to_i
  x, y = (x2 - x1), (y2 - y1)
  q.times do
    xp, yp = input.gets.split(" ").map(&:to_r)
    a = projecter(x, y, xp - x1, yp - y1)
    puts "#{(x1 + a * x).to_f} #{(y1 + a * y).to_f}"
  end
end
main