def len(x, y)
    Math.sqrt(x**2.0 + y**2.0)
end 

p0x, p0y, p1x, p1y = gets.chomp.split(' ').map &:to_i
vx0 = p1x - p0x
vy0 = p1y - p0y
lv0 = len(vx0, vy0)
nvx0 = vx0 / lv0
nvy0 = vy0 / lv0
n = gets.chomp.to_i
n.times do
    x, y = gets.chomp.split(' ').map &:to_i
    vx = x - p0x
    vy = y - p0y
    lv = len(vx, vy)
    c = (vx0 * vx + vy0 * vy) / (lv * lv0)
    l = lv * c
    puts "%.10f %.10f" % [(nvx0 * l), (nvy0 * l)]
end