macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
#[derive(Clone, Copy, Debug, Default, PartialEq)]
pub struct Complex {
    pub x: f64,
    pub y: f64,
}
impl Complex {
    pub fn new(x: f64, y: f64) -> Complex {
        Complex { x: x, y: y }
    }
    pub fn from_radian(theta: f64) -> Complex {
        Complex::new(theta.cos(), theta.sin())
    }
    pub fn abs(self) -> f64 {
        (self.x * self.x + self.y * self.y).sqrt()
    }
    pub fn dot(self, other: Complex) -> f64 {
        self.x * other.x + self.y * other.y
    }
    pub fn cross(self, other: Complex) -> f64 {
        self.x * other.y - self.y * other.x
    }
    pub fn conjugate(self) -> Complex {
        Complex {
            x: self.x,
            y: -self.y,
        }
    }
    pub fn angle(self) -> f64 {
        self.y.atan2(self.x)
    }
}
impl std::ops::Add for Complex {
    type Output = Complex;
    fn add(self, other: Complex) -> Complex {
        Complex {
            x: self.x + other.x,
            y: self.y + other.y,
        }
    }
}
impl std::ops::Add<f64> for Complex {
    type Output = Complex;
    fn add(self, other: f64) -> Complex {
        Complex {
            x: self.x + other,
            y: self.y + other,
        }
    }
}
impl std::ops::Sub for Complex {
    type Output = Complex;
    fn sub(self, other: Complex) -> Complex {
        Complex {
            x: self.x - other.x,
            y: self.y - other.y,
        }
    }
}
impl std::ops::Sub<f64> for Complex {
    type Output = Complex;
    fn sub(self, other: f64) -> Complex {
        Complex {
            x: self.x - other,
            y: self.y - other,
        }
    }
}
impl std::ops::Mul for Complex {
    type Output = Complex;
    fn mul(self, other: Complex) -> Complex {
        Complex {
            x: self.x * other.x - self.y * other.y,
            y: self.x * other.y + self.y * other.x,
        }
    }
}
impl std::ops::Mul<f64> for Complex {
    type Output = Complex;
    fn mul(self, other: f64) -> Complex {
        Complex {
            x: self.x * other,
            y: self.y * other,
        }
    }
}
impl std::ops::Div for Complex {
    type Output = Complex;
    fn div(self, other: Complex) -> Complex {
        self * other.conjugate() / other.abs()
    }
}
impl std::ops::Div<f64> for Complex {
    type Output = Complex;
    fn div(self, other: f64) -> Complex {
        Complex {
            x: self.x / other,
            y: self.y / other,
        }
    }
}
impl std::ops::Neg for Complex {
    type Output = Complex;
    fn neg(self) -> Complex {
        Complex {
            x: -self.x,
            y: -self.y,
        }
    }
}
#[derive(Clone, Debug, PartialEq)]
pub struct Line {
    p1: Complex,
    p2: Complex,
}
impl Line {
    pub fn new(p1: Complex, p2: Complex) -> Line {
        Line { p1: p1, p2: p2 }
    }
    pub fn from_param(a: f64, b: f64, x1: f64, x2: f64) -> Line {
        Line {
            p1: Complex::new(x1, a * x1 + b),
            p2: Complex::new(x2, a * x2 + b),
        }
    }
    pub fn projection(&self, p: Complex) -> Complex {
        let e = self.p2 - self.p1;
        let e = e / e.abs();
        let t = (p - self.p1).dot(e);
        self.p1 + e * t
    }
}
fn main() {
    input! { line: [(f64, f64); 2], q, ps: [(f64, f64); q] };
    let line = line
        .into_iter()
        .map(|(x, y)| Complex::new(x, y))
        .collect::<Vec<_>>();
    let ps = ps
        .into_iter()
        .map(|(x, y)| Complex::new(x, y))
        .collect::<Vec<_>>();
    let l = Line::new(line[0], line[1]);
    for i in 0..q {
        let a = l.projection(ps[i]);
        println!("{} {}", a.x, a.y);
    }
}



Measured memory_bytes: 5088