import Control.Applicative ((<$>))
import Control.Monad
import Data.Complex
import Text.Printf

type Vector = Complex Double

dot :: Vector -> Vector -> Double
dot a b = realPart $ conjugate a * b

normalize :: Vector -> Vector
normalize = signum

readWords :: Read a => IO [a]
readWords = map read . words <$> getLine

main :: IO ()
main = do
  [x1,y1,x2,y2] <- readWords :: IO [Double]
  let
    p1 = x1:+y1
    p2 = x2:+y2
    d = normalize (p2-p1)

  q <- readLn

  ps <- replicateM q $ do
    [x,y] <- readWords :: IO [Double]
    return $ x:+y

  forM_ ps $ \p -> do
    let x:+y = p1+((p-p1)`dot`d:+0)*d
    printf "%.10f %.10f\n" x y