x0, y0, x1, y1 = gets.split.map(&:to_i)
gets.to_i.times do
  x, y = gets.split.map(&:to_i)
  ax = x1 - x0
  ay = y1 - y0
  px = x - x0
  py = y - y0
  # ?????????????????????
  r = (ax * px + ay * py) / (ax * ax + ay * ay).to_f
  puts [x0 + r * ax, y0 + r * ay] * ' '
end