x1, y1, x2, y2 = gets.split.map(&:to_f)
ux = x2 - x1
uy = y2 - y1
d = ux**2 + uy**2
gets.to_i.times do
  x, y = gets.split.map(&:to_f)
  vx, vy = x - x1, y - y1
  k = (vx * ux + vy * uy) / d
  puts '%.8f %.8f' % [x1 + k * ux, y1 + k * uy]
end