type Vector a = (a, a)
add :: (Floating a) => Vector a -> Vector a -> Vector a
add (vx,vy) (wx,wy) = (vx+wx,vy+wy)

neg :: (Floating a) => Vector a -> Vector a
neg (x,y) = (-x,-y)

dotprod :: (Floating a) => Vector a -> Vector a -> a
dotprod (vx,vy) (wx,wy) = vx*wx + vy*wy

sprod :: (Floating a) => a -> Vector a -> Vector a
sprod c (x,y) = (c*x, c*y)

norm :: (Floating a) => Vector a -> a
norm (x,y) = x**2 + y**2

pshow :: (Show a) => Vector a -> String
pshow (x,y) = show x ++ ' ':show y

v = (1,2) :: Vector Float
w = (3,0) :: Vector Float

main = do
    [ax,ay,bx,by] <- map read . words `fmap` getLine :: IO [Float]
    let (a,b) = ((ax,ay),(bx,by)) :: (Vector Float, Vector Float)
    q <- read `fmap` getLine :: IO Int
    points <- sequence (take q (repeat ((\[x,y] -> (x,y)) . map read . words `fmap` getLine))) :: IO [Vector Float]
    mapM (putStrLn . pshow) $ solve a b points

solve :: (Floating a) => Vector a -> Vector a -> [Vector a] -> [Vector a]
solve va vb = map (intersection va vb)

intersection :: (Floating a) => Vector a -> Vector a -> Vector a -> Vector a
intersection a b p = a `add` (sprod coeff b_a)
    where b_a = add b (neg a)
          p_a = add p (neg a)
          coeff = dotprod b_a p_a / norm b_a

