let to_z x = if x = -0. then 0. else x;;
let read_str u = read_line u |> Str.split (Str.regexp_string " ")
           |> List.map (fun x-> float_of_string x) |> List.nth;;
let () =
  let fl = read_str () in
  let x0, y0, x1, y1 = fl 0, fl 1, fl 2, fl 3 and
      n = read_int () in
  let p1_proj = (x1 -.x0) and in_proj = (x1 *. x1 +. y1 *. y0) in
  let rec read i =
    let fl2 = read_str () in
    let x2, y2 = fl2 0, fl2 1 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);;