import Control.Monad
import Data.Matrix

type Vector a = Matrix a

vector :: [a] -> Vector a
vector xs = fromList n 1 xs
    where n = length xs

dot :: Num a => Vector a -> Vector a -> a
dot a b = sum $ transpose a * b

norm :: Num a => Vector a -> a
norm = sum.fmap (^2)

main = do
    [x1,y1,x2,y2] <- map read.words<$>getLine :: IO [Double]
    let v1 = vector [x1,y1]
        v2 = vector [x2,y2]
    q <- readLn
    ps <- replicateM q (vector.map read.words<$>getLine)
    mapM_ (putStrLn.unwords.map show.toList.solve v1 v2) ps

solve :: Vector Double -> Vector Double -> Vector Double -> Vector Double
solve v1 v2 vp = scaleMatrix scale v12
    where scale = dot v1p v12 / norm v12
          v12 = v2 - v1
          v1p = vp - v1