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

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()
    val sqr = vx*vx + vy*vy
    val (vsqxx, vsqxy, vsqyy) = ((vx*vx)/sqr,(vy*vx)/sqr, (vy*vy)/sqr)

    val str = new StringBuilder
    for( i <- 1 to n ) {
      val l2 = readLine().split(" ").map(_.toDouble)
      val (vx2, vy2) = (l2(0)-l(0),l2(1)-l(1))
      val (xt, yt) = ( vsqxx*vx2 + vsqxy*vy2 + l(0), vsqxy*vx2 + vsqyy*vy2 + l(1) )

      str ++= xt + " "+ yt + "\n"
    }
    print(str.toString)
  }
}