x1, y1, x2, y2 = gets.split.map(&:to_f)
vx = x2 - x1
vy = y2 - y1
rv = Math.sqrt(vx*vx+vy*vy)
#normarize
vx /= rv
vy /= rv
q = gets.to_i
q.times{
  x, y = gets.split.map(&:to_f)
  rp1x = (x-x1)*vx+(y-y1)*vy
  puts "%.12f %.12f" % [rp1x*vx + x1, rp1x*vy + y1]
}