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 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-.x0)*.(x2-.x0)+.(y1-.y0)*.(y2-.y0)) in
    let xt,yt = in_p*.(x1-.x0)/.p1_sqr,in_p*.(y1-.y0)/.p1_sqr in
    Printf.printf "%.10f %.10f\n" xt yt;
    if i > 0 then read (i-1)
  in read (n-1);;