fn main() {
    let mut sc = Scanner::new();

    let p1 = Pt::new(sc.next(), sc.next());
    let p2 = Pt::new(sc.next(), sc.next());
    let n = sc.next::<usize>();

    for _ in 0..n {
        let p = Pt::new(sc.next(), sc.next());

        let v = p2 - p1;
        let p = (p - p1) / v;
        let x = Pt::new(p.re, 0.0);
        let x = x * v;
        let x = x + p1;
        println!("{:.12} {:.12}", x.re, x.im);
    }
}

//==========

use std::fmt::Debug;
use std::str::FromStr;

pub struct Scanner {
    buf: Vec<char>,
    cur: usize,
}

impl Scanner {
    pub fn new() -> Scanner {
        Scanner {
            buf: vec![],
            cur: 0,
        }
    }

    fn fill(&mut self) {
        let mut s = String::new();
        let len = std::io::stdin().read_line(&mut s).unwrap();
        if len == 0 {
            panic!("unexpected EOF");
        }
        for c in s.chars() {
            self.buf.push(c);
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: Debug,
    {
        'outer: loop {
            if self.cur >= self.buf.len() {
                self.fill();
            }
            while self.cur < self.buf.len() {
                if !self.buf[self.cur].is_whitespace() {
                    break 'outer;
                }
                self.cur += 1;
            }
        }

        let mut s = String::new();
        while self.cur < self.buf.len() && !self.buf[self.cur].is_whitespace() {
            s.push(self.buf[self.cur]);
            self.cur += 1;
        }
        s.parse().expect("parse error")
    }

    pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T>
    where
        T::Err: Debug,
    {
        let n: usize = self.next();
        self.next_vec(n)
    }

    pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }
}

//==========

#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug, Default)]
#[repr(C)]
pub struct Complex<T> {
    /// Real portion of the complex number
    pub re: T,
    /// Imaginary portion of the complex number
    pub im: T,
}

pub type Complex32 = Complex<f32>;
pub type Complex64 = Complex<f64>;

impl<T> Complex<T> {
    /// Create a new Complex
    #[inline]
    pub fn new(re: T, im: T) -> Self {
        Complex { re, im }
    }
}

use std::ops::{Add, Div, Mul, Sub};

impl<T: Add<Output = T>> Add for Complex<T> {
    type Output = Self;
    fn add(self, rhs: Self) -> Self::Output {
        Self::new(self.re + rhs.re, self.im + rhs.im)
    }
}

impl<T: Sub<Output = T>> Sub for Complex<T> {
    type Output = Self;
    fn sub(self, rhs: Self) -> Self::Output {
        Self::new(self.re - rhs.re, self.im - rhs.im)
    }
}

impl<T: Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T>> Mul for Complex<T> {
    type Output = Self;
    fn mul(self, rhs: Self) -> Self::Output {
        Self::new(
            self.re * rhs.re - self.im * rhs.im,
            self.re * rhs.im + self.im * rhs.re,
        )
    }
}

impl<T: Copy + Add<Output = T> + Sub<Output = T> + Mul<Output = T> + Div<Output = T>> Div
    for Complex<T>
{
    type Output = Self;
    fn div(self, rhs: Self) -> Self::Output {
        let d = rhs.re * rhs.re + rhs.im * rhs.im;
        Self::new(
            (self.re * rhs.re + self.im * rhs.im) / d,
            (self.im * rhs.re - self.re * rhs.im) / d,
        )
    }
}

type Pt = Complex<f64>;



Measured memory_bytes: 5080