let to_z x = if x = -0. then 0. else x;;

let () =
  let (x0,y0,x1,y1) = Scanf.scanf "%f %f %f %f\n" ( fun x0 y0 x1 y1 -> (x0,y0,x1,y1) ) and
      n = read_int () in
  let p1_proj = (x1 -.x0) and in_proj = (x1 *. x1 +. y1 *. y0) in
  let rec read i =
    let (x2,y2) = Scanf.scanf "%f %f\n" (fun x2 y2 -> (x2,y2)) in
    let p1_sqr = ( (x1-.x0)**2. +. (y1-.y0)**2. ) and in_p = (x1*.x2+.y1*.y2) in
    let xt = (in_p*.in_proj/.(p1_sqr*.p1_proj)) and
        yt = ( in_p *. sqrt(p1_sqr *. (p1_proj**2.) -. in_proj**2. )/.(p1_sqr*.p1_proj)) in
    Printf.printf "%f %f\n" (to_z xt) (to_z yt);
    if i > 0 then read (i-1)
  in read (n-1);;