import scala.io.StdIn.{readLine,readInt}
import scala.math.pow

object Main {
  def main(args: Array[String]) = {
    val l = readLine() split " " map (_.toDouble)
    val (vx, vy) = (l(2)-l(0), l(3)-l(1))
    val n = readInt()

    for( i <- 1 to n ) {
      val l2 = readLine() split " " map (_.toDouble)
      val (vx2, vy2) = (l2(0)-l(0), l2(1)-l(1))
      val sqr = pow(vx,2) + pow(vy,2)
      val in_p = vx*vx2 + vy*vy2
      val (xt, yt) = ( in_p*vx/sqr + l(0), in_p*vy/sqr + l(1) )

      println(xt+" "+yt)
    }
  }
}