For given three points p1, p2, p, find the projection point x of p onto p1p2.

<image>

Constraints

* 1 ≤ q ≤ 1000
* -10000 ≤ xi, yi ≤ 10000
* p1 and p2 are not identical.

Input


xp1 yp1 xp2 yp2
q
xp0 yp0
xp1 yp1
...
xpq−1 ypq−1


In the first line, integer coordinates of p1 and p2 are given. Then, q queries are given for integer coordinates of p.

Output

For each query, print the coordinate of the projection point x. The output values should be in a decimal fraction with an error less than 0.00000001.

Examples

Input

0 0 2 0
3
-1 1
0 1
1 1


Output

-1.0000000000 0.0000000000
0.0000000000 0.0000000000
1.0000000000 0.0000000000


Input

0 0 3 4
1
2 5


Output

3.1200000000 4.1600000000

Source: aizu | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
import sys

class Segment(object):
	__slots__ = ('source', 'target')

	def __init__(self, source, target):
		self.source = complex(source)
		self.target = complex(target)

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def solve(_prj_points):
	for point in _prj_points:
		(xp, yp) = map(int, point)
		p = xp + yp * 1j
		prj = project(prj_segment, p)
		print('{real:.10f} {imag:.10f}'.format(real=prj.real, imag=prj.imag))
	return None
_input = sys.stdin.readlines()
line = tuple(map(int, _input[0].split()))
(p1, p2) = (x + y * 1j for (x, y) in zip(line[::2], line[1::2]))
prj_segment = Segment(p1, p2)
q_num = int(_input[1])
prj_points = map(lambda x: x.split(), _input[2:])
solve(prj_points)


import sys
from itertools import starmap
readline = sys.stdin.readline

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
	p2 = complex(*map(float, readline().split()))
	ap = project(s, p2)
	print(ap.real, ap.imag)


def dot(a, b):
	return a[0] * b[0] + a[1] * b[1]
(x1, y1, x2, y2) = map(int, input().split())
a = [x2 - x1, y2 - y1]
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	b = [x - x1, y - y1]
	co = dot(a, b) / dot(a, a)
	print(a[0] * co + x1, a[1] * co + y1)


import sys

def solve(_prj_info):
	for point in _prj_info:
		(xp, yp) = map(int, point)
		p = xp + yp * 1j
		hypo = p - p1
		prj = p1 + base * project(base, hypo)
		print('{0:.10f} {1:.10f}'.format(prj.real, prj.imag))
	return _prj_info

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(a, b):
	return dot(a, b) / dot(a, a)
_input = sys.stdin.readlines()
base_info = _input[0].split()
q_num = int(_input[1])
prj_points = map(lambda x: x.split(), _input[2:])
(x1, y1, x2, y2) = map(int, base_info)
(p1, p2) = (x1 + y1 * 1j, x2 + y2 * 1j)
base = p2 - p1
res = solve(prj_points)


import math

class Point:

	def __init__(self, x=None, y=None):
		self.x = x
		self.y = y

class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.abs = math.sqrt(x * x + y * y)

	def constant_multipled(self, c):
		return Vector(self.x * c, self.y * c)

	def inner_product(self, vec):
		return self.x * vec.x + self.y * vec.y
(x1, y1, x2, y2) = list(map(int, input().split(' ')))
start = Point(x1, y1)
base_vec = Vector(x2 - x1, y2 - y1)
q = int(input())
vectors = []
for i in range(q):
	(x, y) = list(map(int, input().split(' ')))
	vectors.append(Vector(x - start.x, y - start.y))
for vec in vectors:
	if vec.abs == 0:
		(ans_x, ans_y) = (0, 0)
		print('%.8f' % ans_x, '%.8f' % ans_y)
		continue
	cos = base_vec.inner_product(vec) / (base_vec.abs * vec.abs)
	b_cos = vec.abs * cos
	vec_x = base_vec.constant_multipled(b_cos / base_vec.abs)
	(ans_x, ans_y) = (vec_x.x + start.x, vec_x.y + start.y)
	print('%.8f' % ans_x, '%.8f' % ans_y)


def Projection(point, begin, end):
	tmp = (point - begin) / (end - begin)
	return tmp.real * (end - begin) + begin
(a, b, c, d) = map(int, input().split())
(q, r) = (complex(a, b), complex(c, d))
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	p = complex(x, y)
	proj = Projection(p, q, r)
	print(proj.real, proj.imag)


class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def is_orthogonal(self, v):
		if self.x * v.x + self.y * v.y == 0:
			return True
		else:
			return False

	def is_parallel(self, v):
		if self.x * v.y - self.y * v.x == 0:
			return True
		else:
			return False

	def dot_product(self, v):
		return self.x * v.x + self.y * v.y

	def quadrance(self):
		return self.x ** 2 + self.y ** 2

	def mul(self, k):
		return Vector(self.x * k, self.y * k)

	def __add__(self, v):
		return Vector(self.x + v.x, self.y + v.y)

	def __str__(self):
		return '{0:.8f} {1:.8f}'.format(self.x, self.y)

	def project_vector(self, v):
		return v.mul(self.dot_product(v) / v.quadrance())
import sys
file_input = sys.stdin
(x_p1, y_p1, x_p2, y_p2) = map(int, file_input.readline().split())
p1_p2 = Vector(x_p2 - x_p1, y_p2 - y_p1)
o_p1 = Vector(x_p1, y_p1)
q = int(file_input.readline())
for line in file_input:
	(x_p, y_p) = map(int, line.split())
	p1_p = Vector(x_p - x_p1, y_p - y_p1)
	print(o_p1 + p1_p.project_vector(p1_p2))


(x1, y1, x2, y2) = map(float, input().split())
q = int(input())
(x, y) = ([], [])
for i in range(q):
	(x_t, y_t) = map(float, input().split())
	x.append(x_t)
	y.append(y_t)
if x1 == x2:
	for i in range(q):
		print(x1, y[i])
elif y1 == y2:
	for i in range(q):
		print(x[i], y1)
else:
	a = (y2 - y1) / (x2 - x1)
	b = y1 - a * x1
	for i in range(q):
		d = y[i] + 1 / a * x[i]
		px = (d - b) / (a + 1 / a)
		py = a * px + b
		print(px, py)


(xp1, yp1, xp2, yp2) = map(int, input().split())
q = int(input())
if xp1 == xp2:
	for i in range(q):
		(x0, y0) = map(int, input().split())
		print('{:.10f}'.format(xp1), '{:.10f}'.format(y0))
else:
	a = float((yp2 - yp1) / (xp2 - xp1))
	for i in range(q):
		(x0, y0) = map(int, input().split())
		x = a * (y0 - yp1 - a * (x0 - xp1)) / (1 + a ** 2) + x0
		y = (a * (a * y0 + x0 - xp1) + yp1) / (1 + a ** 2)
		print('{:.10f}'.format(x), '{:.10f}'.format(y))


class Vector:
	__slots__ = ['x', 'y']

	def __init__(self, x, y):
		(self.x, self.y) = (x, y)

	def __add__(self, other):
		return self.__class__(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return self.__class__(self.x - other.x, self.y - other.y)

	def __mul__(self, x):
		return self.__class__(self.x * x, self.y * x)

	def __truediv__(self, x):
		return self.__class__(self.x / x, self.y / x)

	def norm(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

def dot(u, v):
	return u.x * v.x + u.y * v.y
(x1, y1, x2, y2) = map(float, input().split())
(p1, p2) = (Vector(x1, y1), Vector(x2, y2))
n = (p2 - p1) / (p2 - p1).norm()
q = int(input())
for _ in range(q):
	p = Vector(*map(float, input().split()))
	p_new = p1 + n * dot(p - p1, n)
	print(p_new.x, p_new.y)


import collections
import math

class Vector2(collections.namedtuple('Vector2', ['x', 'y'])):

	def __add__(self, other):
		return Vector2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector2(self.x - other.x, self.y - other.y)

	def __mul__(self, scalar):
		return Vector2(self.x * scalar, self.y * scalar)

	def __neg__(self):
		return Vector2(-self.x, -self.y)

	def __pos__(self):
		return Vector2(+self.x, +self.y)

	def __abs__(self):
		return math.sqrt(float(self.x * self.x + self.y * self.y))

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x
(a, b, c, d) = map(int, input().split())
p1 = Vector2(a, b)
p2 = Vector2(c, d)
base = p2 - p1
q = int(input())
for _ in range(q):
	(e, f) = map(int, input().split())
	hypo = Vector2(e - a, f - b)
	x = p1 + base * (hypo.dot(base) / abs(base) ** 2)
	print(x.x, x.y)


(xp1, yp1, xp2, yp2) = map(int, input().split())
q = int(input())
r = (xp2 - xp1, yp2 - yp1)

def a(p1, p2):
	s = (p1 - xp1, p2 - yp1)
	d = r[0] * s[0] + r[1] * s[1]
	a = xp1 + r[0] * d / (r[0] ** 2 + r[1] ** 2)
	b = yp1 + r[1] * d / (r[0] ** 2 + r[1] ** 2)
	return (str(a), str(b))
for i in range(q):
	(x, y) = map(int, input().split())
	print(' '.join(a(x, y)))


import math
HORIZONTAL = 0
VERTICAL = 1
ELSE = 2
mode = ELSE
(x_p1, y_p1, x_p2, y_p2) = [int(i) for i in input().split()]
if x_p2 - x_p1 == 0:
	mode = VERTICAL
elif y_p2 - y_p1 == 0:
	mode = HORIZONTAL
else:
	a = (y_p2 - y_p1) / (x_p2 - x_p1)
	b = y_p1 - a * x_p1
q = int(input())
for _ in range(q):
	(x_p0, y_p0) = [int(i) for i in input().split()]
	u = x_p0 - x_p1
	v = y_p0 - y_p1
	if mode == VERTICAL:
		print(x_p1, y_p0)
	elif mode == HORIZONTAL:
		print(x_p0, y_p1)
	else:
		x = (x_p0 / a + y_p0 - b) / (a + 1 / a)
		y = a * x + b
		print(x, y)


class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Point(self.x * other, self.y * other)

	def __floordiv__(self, other):
		return Point(self.x / other, self.y / other)

	def __repr__(self):
		return str(self.x) + ' ' + str(self.y)

class Vector(Point):
	pass

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

def points_to_vector(p1, p2):
	x = p1.x - p2.x
	y = p1.y - p2.y
	return Vector(x, y)

def vector(p):
	return Vector(p.x, p.y)

def dot(v1, v2):
	return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
	return v1.x * v2.y - v1.y * v2.x

def norm(v):
	return v.x ** 2 + v.y ** 2

def project(s, p):
	base = points_to_vector(s.p1, s.p2)
	hypo = points_to_vector(p, s.p1)
	r = dot(hypo, base) / norm(base)
	return s.p1 + base * r
import sys
s = list(map(int, input().split()))
p1 = Point(s[0], s[1])
p2 = Point(s[2], s[3])
segment = Segment(p1, p2)
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	p = Point(x, y)
	ans = project(segment, p)
	print(ans)


from math import sqrt

def inner_product(vect1, vect2):
	return sum([v1_el * v2_el for (v1_el, v2_el) in zip(vect1, vect2)])

def vector_abs(vect):
	return sqrt(sum([element ** 2 for element in vect]))

def direction_unit_vector(p_from, p_to):
	d_vector = [xt - xf for (xt, xf) in zip(p_to, p_from)]
	d_u_vector = [element / vector_abs(d_vector) for element in d_vector]
	return d_u_vector

def projection(origin, line_from, line_to):
	direction_unit = direction_unit_vector(line_from, line_to)
	origin_d_vector = [org - lf for (org, lf) in zip(origin, line_from)]
	inject_dist = inner_product(direction_unit, origin_d_vector)
	on_line_vect = [inject_dist * element for element in direction_unit]
	return [olv_el + lf_el for (olv_el, lf_el) in zip(on_line_vect, line_from)]
xy_list = list(map(int, input().split()))
p1_list = xy_list[:2]
p2_list = xy_list[2:]
Q = int(input())
for i in range(Q):
	p_list = list(map(int, input().split()))
	x_list = projection(p_list, p1_list, p2_list)
	print(' '.join(map(str, x_list)))


import sys

class Segment(object):
	__slots__ = ('source', 'target')

	def __init__(self, source, target):
		self.source = complex(source)
		self.target = complex(target)

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def solve(_prj_points):
	for point in _prj_points:
		(xp, yp) = map(int, point)
		p = xp + yp * 1j
		prj = project(prj_segment, p)
		print('{real:.10f} {imag:.10f}'.format(real=prj.real, imag=prj.imag))
	return None
_input = sys.stdin.readlines()
line = tuple(map(int, _input[0].split()))
q_num = int(_input[1])
(p1, p2) = (x + y * 1j for (x, y) in zip(line[::2], line[1::2]))
prj_segment = Segment(p1, p2)
prj_points = map(lambda x: x.split(), _input[2:])
solve(prj_points)


from typing import List
from math import sqrt
EPS = 1e-10

def float_equal(x: float, y: float) -> bool:
	return abs(x - y) < EPS

class Point:

	def __init__(self, x: float=0.0, y: float=0.0) -> None:
		self.x = x
		self.y = y

	def __repr__(self) -> str:
		return 'Point({}, {})'.format(self.x, self.y)

	def __eq__(self, other: object) -> bool:
		if not isinstance(other, Point):
			return NotImplemented
		return float_equal(self.x, other.x) and float_equal(self.y, other.y)

	def __add__(self, other: 'Point') -> 'Point':
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other: 'Point') -> 'Point':
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, k: float) -> 'Point':
		return Point(self.x * k, self.y * k)

	def __rmul__(self, k: float) -> 'Point':
		return self * k

	def __truediv__(self, k: float) -> 'Point':
		return Point(self.x / k, self.y / k)

	def __lt__(self, other: 'Point') -> bool:
		return self.y < other.y if abs(self.x - other.x) < EPS else self.x < other.x

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return sqrt(self.norm())

	def dot(self, other: 'Point') -> float:
		return self.x * other.x + self.y * other.y

	def cross(self, other: 'Point') -> float:
		return self.x * other.y - self.y * other.x

	def is_orthogonal(self, other: 'Point') -> bool:
		return float_equal(self.dot(other), 0.0)

	def is_parallel(self, other: 'Point') -> bool:
		return float_equal(self.cross(other), 0.0)
Vector = Point

class Segment:

	def __init__(self, p1: Point=None, p2: Point=None) -> None:
		self.p1: Point = Point() if p1 is None else p1
		self.p2: Point = Point() if p2 is None else p2

	def __repr__(self) -> str:
		return 'Segment({}, {})'.format(self.p1, self.p2)

	def __eq__(self, other: object) -> bool:
		if not isinstance(other, Segment):
			return NotImplemented
		return self.p1 == other.p1 and self.p2 == other.p2

	def vector(self) -> Vector:
		return self.p2 - self.p1

	def is_orthogonal(self, other: 'Segment') -> bool:
		return self.vector().is_orthogonal(other.vector())

	def is_parallel(self, other: 'Segment') -> bool:
		return self.vector().is_parallel(other.vector())

	def projection(self, p: Point) -> Point:
		v = self.vector()
		vp = p - self.p1
		return v.dot(vp) / v.norm() * v + self.p1
Line = Segment

def main():
	(x1, y1, x2, y2) = [int(x) for x in input().split()]
	p1 = Point(x1, y1)
	p2 = Point(x2, y2)
	l = Line(p1, p2)
	q = int(input())
	for _ in range(q):
		(x, y) = [int(x) for x in input().split()]
		p = Point(x, y)
		a = l.projection(p)
		print(a.x, a.y)
main()


import sys
from itertools import starmap
readline = sys.stdin.readline

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r
s = Segment(*list(starmap(complex, zip(*[map(int, readline().split())] * 2))))
n = int(readline())
for _ in [0] * n:
	p2 = complex(*[int(i) for i in readline().split()])
	ap = project(s, p2)
	print(ap.real, ap.imag)


import sys
from collections import namedtuple

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(s, p):
	base_vector = s.target - s.source
	prj_ratio = dot(p - s.source, base_vector) / pow(abs(base_vector), 2)
	return s.source + base_vector * prj_ratio

def solve(_prj_points):
	for point in _prj_points:
		(xp, yp) = map(int, point)
		p = xp + yp * 1j
		prj = project(prj_segment, p)
		print('{real:.10f} {imag:.10f}'.format(real=prj.real, imag=prj.imag))
	return None
_input = sys.stdin.readlines()
line = tuple(map(int, _input[0].split()))
q_num = int(_input[1])
prj_points = map(lambda x: x.split(), _input[2:])
(p1, p2) = (x + y * 1j for (x, y) in zip(line[::2], line[1::2]))
Segment = namedtuple('Segment', ('source', 'target'))
prj_segment = Segment(p1, p2)
solve(prj_points)


import sys
from itertools import starmap
readline = sys.stdin.readline

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r
s = Segment(*list(starmap(complex, zip(*[map(int, readline().split())] * 2))))
n = int(readline())
for _ in [0] * n:
	p2 = complex(*map(float, readline().split()))
	ap = project(s, p2)
	print(ap.real, ap.imag)


from math import pi, cos, sin, atan2
EPS = 10 ** (-9)

def eq(value1, value2):
	return abs(value1 - value2) <= EPS

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.arg = atan2(y, x)

	def __str__(self):
		return '{0:.8f} {1:.8f}'.format(self.x, self.y)

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, scal):
		return Point(self.x * scal, self.y * scal)

	def __truediv__(self, scal):
		return Point(self.x / scal, self.y / scal)

	def __eq__(self, other):
		return eq(self.x, other.x) and eq(self.y, other.y)

	def __abs__(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

def Rotation(vec: Point, rad):
	return Point(vec.x * cos(rad) - vec.y * sin(rad), vec.x * sin(rad) + vec.y * cos(rad))

class Circle:

	def __init__(self, p, r):
		self.p = p
		self.r = r

class Line:

	def __init__(self, a, b):
		self.a = a
		self.b = b
		self.arg = (a - b).arg % pi

	def __str__(self):
		return '[({0}, {1}) - ({2}, {3})]'.format(self.a.x, self.a.y, self.b.x, self.b.y)

	def par(self, point):
		return Line(point, point + (self.a - self.b))

	def tan(self, point):
		return Line(point, point + Rotation(self.a - self.b, pi / 2))

class Segment(Line):

	def __init__(self, a, b):
		super(Line, self).__init__(a, b)

def cross(vec1: Point, vec2: Point):
	return vec1.x * vec2.y - vec1.y * vec2.x

def dot(vec1: Point, vec2: Point):
	return vec1.x * vec2.x + vec1.y * vec2.y

def ccw(a, b, c):
	if cross(b - a, c - a) > EPS:
		return +1
	if cross(b - a, c - a) < -EPS:
		return -1
	if dot(c - a, b - a) < -EPS:
		return +2
	if abs(b - a) < abs(c - a):
		return -2
	return 0

def projection(l, p):
	t = dot(l.b - l.a, p - l.a) / abs(l.a - l.b) ** 2
	return l.a + (l.b - l.a) * t

def reflection(l, p):
	return p + (projection(l, p) - p) * 2

def isPararell(l1, l2):
	return eq(cross(l1.a - l1.b, l2.a - l2.b), 0)

def isVertical(l1, l2):
	return eq(dot(l1.a - l1.b, l2.a - l2.b), 0)

def isIntersect_lp(l, p):
	return abs(ccw(l.a, l.b, p)) != 1

def isIntersect_ll(l1, l2):
	return not isPararell(l1, l2) or isIntersect_lp(l1, l2.a)

def isIntersect_sp(s, p):
	return ccw(s.a, s.b, p) == 0

def isIntersect_ss(s1, s2):
	return ccw(s1.a, s1.b, s2.a) * ccw(s1.a, s1.b, s2.b) <= 0 and ccw(s2.a, s2.b, s1.a) * ccw(s2.a, s2.b, s1.b) <= 0

def isIntersect_ls(l, s):
	return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.a) < EPS

def isIntersect_cp(c, p):
	return abs(abs(c.p - p) - c.r) < EPS

def isIntersect_cl(c, l):
	return distance_lp(l, c.p) <= c.r + EPS

def isIntersect_cs(c, s):
	pass

def isIntersect_cc(c1, c2):
	pass

def distance_pp(p1, p2):
	return abs(p1 - p2)

def distance_lp(l, p):
	return abs(projection(l, p) - p)

def distance_ll(l1, l2):
	return 0 if isIntersect_ll(l1, l2) else distance_lp(l1, l2.a)

def distance_sp(s, p):
	r = projection(s, p)
	if isIntersect_sp(s, r):
		return abs(r - p)
	return min(abs(s.a - p), abs(s.b - p))

def distance_ss(s1, s2):
	if isIntersect_ss(s1, s2):
		return 0
	return min([distance_sp(s1, s2.a), distance_sp(s1, s2.b), distance_sp(s2, s1.a), distance_sp(s2, s1.b)])

def distance_ls(l, s):
	if isIntersect_ls(l, s):
		return 0
	return min(distance_lp(l, s.a), distance_lp(l, s.b))

def crosspoint_ll(l1, l2):
	A = cross(l1.b - l1.a, l2.b - l2.a)
	B = cross(l1.b - l1.a, l1.b - l2.a)
	if eq(abs(A), 0) and eq(abs(B), 0):
		return l2.a
	return l2.a + (l2.b - l2.a) * B / A

def crosspoint_ss(s1, s2):
	return crosspoint_ll(s1, s2)

def crosspoint_lc(l, c):
	if eq(distance_lp(l, c.p), c.r):
		return [c.p]
	p = projection(l, c.p)
	e = (l.b - l.a) / abs(l.b - l.a)
	dis = (c.r ** 2 - abs(p - c.p) ** 2) ** 0.5
	return [p + e * dis, p - e * dis]

def crosspoint_sc(s, c):
	pass

def crosspoint_cc(c1, c2):
	d = abs(c1.p - c2.p)
	if not abs(c1.r - c2.r) <= d <= c1.r + c2.r:
		return []
	mid_p = (c2.p * (c1.r ** 2 - c2.r ** 2 + d ** 2) + c1.p * (c2.r ** 2 - c1.r ** 2 + d ** 2)) / (2 * d ** 2)
	tanvec = Rotation(c1.p - c2.p, pi / 2)
	return crosspoint_lc(Line(mid_p, mid_p + tanvec), c1)

def tangent_cp(c, p):
	return crosspoint_cc(c, Circle(p, (abs(p - c.p) ** 2 - c.r ** 2) ** 0.5))
import sys
input = sys.stdin.readline

def verify_1A():
	(p1x, p1y, p2x, p2y) = map(int, input().split())
	l = Line(Point(p1x, p1y), Point(p2x, p2y))
	Q = int(input())
	Query = [list(map(int, input().split())) for _ in range(Q)]
	for (px, py) in Query:
		p = Point(px, py)
		print(projection(l, p))
verify_1A()


import sys

def solve(_prj_info):
	for point in _prj_info:
		(xp, yp) = map(int, point)
		p = xp + yp * 1j
		hypo = p - p1
		prj = p1 + base_vector * project(base_vector, hypo)
		print('{:.10f} {:.10f}'.format(prj.real, prj.imag))
	return _prj_info

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def project(a, b):
	return dot(a, b) / dot(a, a)
_input = sys.stdin.readlines()
base_info = _input[0].split()
q_num = int(_input[1])
prj_points = map(lambda x: x.split(), _input[2:])
(x1, y1, x2, y2) = map(int, base_info)
(p1, p2) = (x1 + y1 * 1j, x2 + y2 * 1j)
base_vector = p2 - p1
res = solve(prj_points)


import cmath
import os
import sys
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7
PI = cmath.pi
TAU = cmath.pi * 2

class Point:
	EPS = 1e-09

	def __init__(self, c: complex):
		self.c = c

	@property
	def x(self):
		return self.c.real

	@property
	def y(self):
		return self.c.imag

	@staticmethod
	def from_rect(x: float, y: float):
		return Point(complex(x, y))

	@staticmethod
	def from_polar(r: float, phi: float):
		return Point(cmath.rect(r, phi))

	def __add__(self, p):
		return Point(self.c + p.c)

	def __iadd__(self, p):
		self.c += p.c
		return self

	def __sub__(self, p):
		return Point(self.c - p.c)

	def __isub__(self, p):
		self.c -= p.c
		return self

	def __mul__(self, f: float):
		return Point(self.c * f)

	def __imul__(self, f: float):
		self.c *= f
		return self

	def __truediv__(self, f: float):
		return Point(self.c / f)

	def __itruediv__(self, f: float):
		self.c /= f
		return self

	def __repr__(self):
		return '({}, {})'.format(round(self.x, 10), round(self.y, 10))

	def __neg__(self):
		return Point(-self.c)

	def __eq__(self, p):
		return abs(self.c - p.c) < self.EPS

	def __abs__(self):
		return abs(self.c)

	def dot(self, p):
		return self.x * p.x + self.y * p.y

	def det(self, p):
		return self.x * p.y - self.y * p.x

	def dist(self, p):
		return abs(self.c - p.c)

	def r(self):
		return abs(self.c)

	def phase(self):
		return cmath.phase(self.c)

	def angle(self, p, q):
		return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c)) % TAU

	def area(self, p, q):
		return abs((p - self).det(q - self) / 2)

	def projection_point(self, p, q, allow_outer=False):
		diff_q = q - p
		r = (self - p).dot(diff_q) / abs(diff_q)
		phase = diff_q.phase()
		ret = Point.from_polar(r, phase) + p
		if allow_outer or (p - ret).dot(q - ret) < self.EPS:
			return ret
		return None

	def on_segment(self, p, q):
		return abs((p - self).det(q - self)) < self.EPS and (p - self).dot(q - self) < self.EPS
(p1x, p1y, p2x, p2y) = list(map(int, sys.stdin.buffer.readline().split()))
Q = int(sys.stdin.buffer.readline())
XY = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(Q)]
p1 = Point.from_rect(p1x, p1y)
p2 = Point.from_rect(p2x, p2y)
for (x, y) in XY:
	p = Point.from_rect(x, y)
	ans = p.projection_point(p1, p2, allow_outer=True)
	print('{:.10f} {:.10f}'.format(ans.x, ans.y))


(x_p1, y_p1, x_p2, y_p2) = map(lambda x: int(x), input().split())
q = int(input())
p1p2 = (x_p2 - x_p1, y_p2 - y_p1)
for _ in range(q):
	(x_p0, y_p0) = map(lambda x: int(x), input().split())
	p1p0 = (x_p0 - x_p1, y_p0 - y_p1)
	r = (p1p2[0] * p1p0[0] + p1p2[1] * p1p0[1]) / (p1p2[0] ** 2 + p1p2[1] ** 2)
	print(x_p1 + p1p2[0] * r, y_p1 + p1p2[1] * r)


import sys
sys.setrecursionlimit(10 ** 9)

def input():
	return sys.stdin.readline().strip()

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))
INF = float('inf')

def dot(a, b):
	(x1, y1) = a
	(x2, y2) = b
	return x1 * x2 + y1 * y2

def norm(a):
	(x, y) = a
	return x ** 2 + y ** 2

def add(a, b):
	(x1, y1) = a
	(x2, y2) = b
	return (x1 + x2, y1 + y2)

def sub(a, b):
	(x1, y1) = a
	(x2, y2) = b
	return (x1 - x2, y1 - y2)

def mul(a, b):
	(x1, y1) = a
	if not isinstance(b, tuple):
		return (x1 * b, y1 * b)
	(x2, y2) = b
	return (x1 * x2, y1 * y2)

def project(seg, p):
	(p1, p2) = seg
	base = sub(p2, p1)
	r = dot(sub(p, p1), base) / norm(base)
	return add(p1, mul(base, r))
(x1, y1, x2, y2) = MAP()
seg = ((x1, y1), (x2, y2))
Q = INT()
for i in range(Q):
	(x, y) = MAP()
	res = project(seg, (x, y))
	print(*res)


(x0, y0, x1, y1) = map(float, input().split())
n = int(input())
(vx1, vy1) = (x1 - x0, y1 - y0)
for i in range(n):
	(x2, y2) = map(float, input().split())
	(vx2, vy2) = (x2 - x0, y2 - y0)
	sqr = vx1 ** 2 + vy1 ** 2
	in_p = vx1 * vx2 + vy1 * vy2
	(xt, yt) = (in_p * vx1 / sqr + x0, in_p * vy1 / sqr + y0)
	print('{0:.10f} {1:.10f}'.format(xt, yt))


from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
mod = 10 ** 9 + 7
eps = 10 ** (-7)

def inp():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpl_str():
	return list(input().split())

def sgn(a):
	if a < -eps:
		return -1
	if a > eps:
		return 1
	return 0

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		pass

	def tolist(self):
		return [self.x, self.y]

	def __add__(self, p):
		return Point(self.x + p.x, self.y + p.y)

	def __iadd__(self, p):
		return self + p

	def __sub__(self, p):
		return Point(self.x - p.x, self.y - p.y)

	def __isub__(self, p):
		return self - p

	def __truediv__(self, n):
		return Point(self.x / n, self.y / n)

	def __itruediv__(self, n):
		return self / n

	def __mul__(self, n):
		return Point(self.x * n, self.y * n)

	def __imul__(self, n):
		return self * n

	def __lt__(self, other):
		tmp = sgn(self.x - other.x)
		if tmp != 0:
			return tmp < 0
		else:
			return sgn(self.y - other.y) < 0

	def abs(self):
		return math.sqrt(self.x ** 2 + self.y ** 2)

	def dot(self, p):
		return self.x * p.x + self.y * p.y

	def det(self, p):
		return self.x * p.y - self.y * p.x

	def arg(self, p):
		return math.atan2(y, x)

def iSP(a, b, c):
	tmp = sgn((b - a).det(c - a))
	if tmp > 0:
		return 1
	elif tmp < 0:
		return -1
	else:
		if sgn((b - a).dot(c - a)) < 0:
			return -2
		if sgn((a - b).dot(c - b)) < 0:
			return 2
		return 0

def isToleranceLine(a, b, c, d):
	if sgn((b - a).det(c - d)) != 0:
		return 1
	elif sgn((b - a).det(c - a)) != 0:
		return 0
	else:
		return -1

def isToleranceSegline(a, b, c, d):
	return sgn(iSP(a, b, c) * iSP(a, b, d)) <= 0 and sgn(iSP(c, d, a) * iSP(c, d, b)) <= 0

def Intersection(a, b, c, d):
	tmp1 = (b - a) * (c - a).det(d - c)
	tmp2 = (b - a).det(d - c)
	return a + tmp1 / tmp2

def DistanceLineToPoint(a, b, c):
	return abs((c - a).det(b - a) / (b - a).abs())

def DistanceSeglineToPoint(a, b, c):
	if sgn((b - a).dot(c - a)) < 0:
		return (c - a).abs()
	if sgn((a - b).dot(c - b)) < 0:
		return (c - b).abs()
	return DistanceLineToPoint(a, b, c)

def Vfoot(a, b, c):
	d = c + Point((b - a).y, -(b - a).x)
	return Intersection(a, b, c, d)

def PolygonArea(Plist):
	Plist = ConvexHull(Plist)
	L = len(Plist)
	S = 0
	for i in range(L):
		tmpS = Plist[i - 1].det(Plist[i]) / 2
		S += tmpS
	return S

def PolygonG(Plist):
	Plist = ConvexHull(Plist)
	L = len(Plist)
	S = 0
	G = Point(0, 0)
	for i in range(L):
		tmpS = Plist[i - 1].det(Plist[i]) / 2
		S += tmpS
		G += (Plist[i - 1] + Plist[i]) / 3 * tmpS
	return G / S

def ConvexHull(Plist):
	Plist.sort()
	L = len(Plist)
	qu = deque([])
	quL = 0
	for p in Plist:
		while quL >= 2 and iSP(qu[quL - 2], qu[quL - 1], p) == 1:
			qu.pop()
			quL -= 1
		qu.append(p)
		quL += 1
	qd = deque([])
	qdL = 0
	for p in Plist:
		while qdL >= 2 and iSP(qd[qdL - 2], qd[qdL - 1], p) == -1:
			qd.pop()
			qdL -= 1
		qd.append(p)
		qdL += 1
	qd.pop()
	qu.popleft()
	hidari = list(qd) + list(reversed(qu))
	return hidari
(x1, y1, x2, y2) = inpl()
(a, b) = (Point(x1, y1), Point(x2, y2))
q = inp()
for _ in range(q):
	p = Point(*inpl())
	print(*Vfoot(a, b, p).tolist())


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, a):
		return self.__class__(self.x + a.x, self.y + a.y)

	def __sub__(self, a):
		return self.__class__(self.x - a.x, self.y - a.y)

	def __mul__(self, d):
		return self.__class__(self.x * d, self.y * d)

	def __truediv__(self, d):
		return self.__class__(self.x / d, self.y / d)

	def __str__(self):
		return '%.10f %.10f' % (self.x, self.y)

	def abs(self):
		return self.norm() ** (1.0 / 2.0)

	def norm(self):
		return self.x * self.x + self.y * self.y

	def rotate(self, d):
		r = math.pi * d / 180.0
		return self.__class__(self.x * math.cos(r) - self.y * math.sin(r), self.x * math.sin(r) + self.y * math.cos(r))

	def dot(self, p):
		return self.x * p.x + self.y * p.y

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

def reflect(s, p):
	v = s.p2 - s.p1
	r = v.dot(p - s.p1) / v.norm()
	return s.p1 + v * r

def main():
	(a, b, c, d) = map(float, input().split())
	s = Segment(Point(a, b), Point(c, d))
	q = int(input())
	for _ in range(q):
		(e, f) = map(float, input().split())
		p = Point(e, f)
		print(reflect(s, p))
main()


(a, b, c, d) = map(float, input().split())
c -= a
d -= b
for _ in [0] * int(input()):
	(x, y) = map(float, input().split())
	x -= a
	y -= b
	z = (c * x + d * y) / (c * c + d * d)
	print(a + c * z, b + d * z)


import collections
import math

class Vector2(collections.namedtuple('Vector2', ['x', 'y'])):

	def __add__(self, other):
		return Vector2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector2(self.x - other.x, self.y - other.y)

	def __mul__(self, scalar):
		return Vector2(self.x * scalar, self.y * scalar)

	def __neg__(self):
		return Vector2(-self.x, -self.y)

	def __pos__(self):
		return Vector2(+self.x, +self.y)

	def __abs__(self):
		return math.sqrt(float(self.x * self.x + self.y * self.y))

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x
(a, b, c, d) = map(int, input().split())
p1 = Vector2(a, b)
p2 = Vector2(c, d)
base = p2 - p1
q = int(input())
for _ in range(q):
	(e, f) = map(int, input().split())
	hypo = Vector2(e - a, f - b)
	r = hypo.dot(base) / abs(base) ** 2
	x = p1 + base * r
	print(x.x, x.y)


import math
line = input()
(x1, y1, x2, y2) = list(map(int, line.split()))
line = input()
q = int(line)
pts = []
for _ in range(0, q):
	line = input()
	(x, y) = list(map(int, line.split()))
	pts += [[x, y]]

def solve():
	l1 = math.sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
	for (x, y) in pts:
		l2 = math.sqrt((x - x1) ** 2 + (y - y1) ** 2)
		dx = (x2 - x1) / l1
		dy = (y2 - y1) / l1
		ip = (x - x1) * (x2 - x1) + (y - y1) * (y2 - y1)
		xx = x1 + dx * ip / l1
		yy = y1 + dy * ip / l1
		print(xx, yy)
solve()


import sys
input = sys.stdin.readline

def main():
	(x1, y1, x2, y2) = list(map(int, input().split()))
	a = [x2 - x1, y2 - y1]
	lal2 = a[0] ** 2 + a[1] ** 2
	q = int(input())
	for i in range(q):
		(x, y) = map(int, input().split())
		b = [x - x1, y - y1]
		t = (a[0] * b[0] + a[1] * b[1]) / lal2
		print(x1 + a[0] * t, y1 + a[1] * t)
main()


pxylist = []
result = []
(xp1, yp1, xp2, yp2) = map(int, input().split())
q = int(input())

def recieve():
	for i in range(q):
		pxy = list(map(int, input().split()))
		pxylist.append(pxy)
if xp2 == xp1:
	recieve()
	for i in range(q):
		result.append([xp1, pxylist[i][1]])
elif yp1 == yp2:
	recieve()
	for i in range(q):
		result.append([pxylist[i][0], yp1])
else:
	a = (yp2 - yp1) / (xp2 - xp1)
	b = yp1 - a * xp1
	recieve()
	for i in range(q):
		pxi = pxylist[i][0]
		pyi = pxylist[i][1]
		x = (a * (pyi - b) + pxi) / (a * a + 1)
		y = a * x + b
		result.append([x, y])
for i in range(q):
	print(str(result[i][0]) + ' ' + str(result[i][1]))


L1 = input().split()
[xp1, yp1, xp2, yp2] = [int(L1[0]), int(L1[1]), int(L1[2]), int(L1[3])]
direction = [xp2 - xp1, yp2 - yp1]
norm_direc = [(xp2 - xp1) / ((xp2 - xp1) ** 2 + (yp2 - yp1) ** 2) ** (1 / 2), (yp2 - yp1) / ((xp2 - xp1) ** 2 + (yp2 - yp1) ** 2) ** (1 / 2)]
q = int(input())
L = []
for i in range(q):
	L2 = input().split()
	L.append([int(L2[0]), int(L2[1])])
Point = []
for i in range(q):
	Point.append([L[i][0] - xp1, L[i][1] - yp1])
Vec = []
for i in range(q):
	Vec.append([L[i][0] - xp1, L[i][1] - yp1])
Proj = []
for i in range(q):
	inter = Vec[i][0] * norm_direc[0] + Vec[i][1] * norm_direc[1]
	Proj.append([norm_direc[0] * inter, norm_direc[1] * inter])
L2 = []
for i in range(q):
	L2.append([xp1 + Proj[i][0], yp1 + Proj[i][1]])
for i in range(q):
	print(*L2[i])


import math
EPS = 1e-10

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, point):
		return Point(self.x + point.x, self.y + point.y)

	def __sub__(self, point):
		return Point(self.x - point.x, self.y - point.y)

	def __mul__(self, a):
		return Point(a * self.x, a * self.y)

	def __truediv__(self, a):
		return Point(self.x / a, self.y / a)

	def __abs__(self):
		return math.sqrt(self.norm())

	def norm(self):
		return self.x ** 2 + self.y ** 2

	def __eq__(self, point):
		return abs(self.x - point.x) < EPS and abs(self.y - point.y) < EPS

def dot(a, b):
	return a.x * b.x + a.y * b.y

def cross(a, b):
	return a.x * b.y - a.y * b.x

def isOrthogonal(a, b):
	return dot(a, b) == 0

def isParallel(a, b):
	return cross(a, b) == 0

def project(s, p):
	base = s.p2 - s.p1
	r = dot(p - s.p1, base) / base.norm()
	return s.p1 + base * r
from sys import stdin
input = stdin.readline
(x1, y1, x2, y2) = map(int, input().split())
s = Segment(Point(x1, y1), Point(x2, y2))
q = int(input())
for _ in range(q):
	(x0, y0) = map(int, input().split())
	p = Point(x0, y0)
	projection = project(s, p)
	print(projection.x, projection.y)


from math import hypot
(x1, y1, x2, y2) = map(int, input().split())
(dx, dy) = (x2 - x1, y2 - y1)
vector_base = hypot(dx, dy)
q = int(input())
for i in range(q):
	(x3, y3) = map(int, input().split())
	d = ((x3 - x1) * dx + (y3 - y1) * dy) / vector_base ** 2
	print(x1 + dx * d, y1 + dy * d)


from sys import stdin
readline = stdin.readline

def main():
	(x1, y1, x2, y2) = map(int, readline().split())
	(p1, p2) = (x1 + y1 * 1j, x2 + y2 * 1j)
	for i in range(int(readline())):
		(xi, yi) = map(int, readline().split())
		pi = xi + yi * 1j
		cross = p1 + (p2 - p1) * projecter(p2 - p1, pi - p1)
		print('{:.10f} {:.10f}'.format(cross.real, cross.imag))

def projecter(a, b):
	return dot(a, b) / dot(a, a)

def dot(a, b):
	return a.real * b.real + a.imag * b.imag
main()


from math import hypot
(x1, y1, x2, y2) = map(int, input().split())
(dx, dy) = (x2 - x1, y2 - y1)
vector_a = hypot(dx, dy)
q = int(input())
for (x3, y3) in (map(int, input().split()) for _ in [0] * q):
	d = ((x3 - x1) * dx + (y3 - y1) * dy) / vector_a ** 2
	print(x1 + dx * d, y1 + dy * d)


import math

class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def norm_2(self):
		return dot(self, self)

	def norm(self):
		return math.sqrt(self.norm_2())

def v_sum(v1, v2):
	return Vector(v1.x + v2.x, v1.y + v2.y)

def v_diff(v1, v2):
	return Vector(v1.x - v2.x, v1.y - v2.y)

def scalar_multi(k, v):
	return Vector(k * v.x, k * v.y)

def dot(vector1, vector2):
	return vector1.x * vector2.x + vector1.y * vector2.y

def cross(vector1, vector2):
	return vector1.x * vector2.y + vector1.y * vector2.x
(x1, y1, x2, y2) = map(int, input().split())
p1 = Vector(x1, y1)
p2 = Vector(x2, y2)
d = v_diff(p2, p1)
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	v = v_diff(Vector(x, y), p1)
	u = v_sum(scalar_multi(dot(v, d) / d.norm_2(), d), p1)
	print('{} {}'.format(round(u.x, 9), round(u.y, 9)))


def proj(p1, p2, p):
	(x1, y1) = p1
	(x2, y2) = p2
	(x, y) = p
	if x1 == x2:
		return (x1 * 1.0, y * 1.0)
	elif y1 == y2:
		return (x * 1.0, y1 * 1.0)
	else:
		dx = x1 - x2
		dy = y1 - y2
		return (((dx * x + dy * y) * dx - (x1 * y2 - x2 * y1) * dy) / (dx * dx + dy * dy), ((dx * x + dy * y) * dy + (x1 * y2 - x2 * y1) * dx) / (dx * dx + dy * dy))

def run():
	(px1, py1, px2, py2) = [int(v) for v in input().split()]
	q = int(input())
	for _ in range(q):
		(x, y) = [int(v) for v in input().split()]
		print('{:.10f} {:.10f}'.format(*proj((px1, py1), (px2, py2), (x, y))))
run()


def dot(a, b):
	return a[0] * b[0] + a[1] * b[1]
(x1, y1, x2, y2) = [int(i) for i in input().split()]
q = int(input())
for i in range(q):
	(x, y) = [int(i) for i in input().split()]
	a = [x2 - x1, y2 - y1]
	b = [x - x1, y - y1]
	co = dot(a, b) / dot(a, a)
	print(a[0] * co + x1, a[1] * co + y1)


from sys import stdin

class Vector:

	def __init__(self, x=None, y=None):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, k):
		return Vector(self.x * k, self.y * k)

	def __gt__(self, other):
		return self.x > other.x and self.y > other.y

	def __eq__(self, other):
		return self.x == other.x and self.y == other.y

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return math.sqrt(self.norm())

class Point(Vector):

	def __init__(self, *args, **kargs):
		return super().__init__(*args, **kargs)

class Segment:

	def __init__(self, p1=Point(0, 0), p2=Point(1, 1)):
		self.p1 = p1
		self.p2 = p2

def project(s, p):
	base = s.p2 - s.p1
	hypo = p - s.p1
	r = hypo.dot(base) / base.norm()
	return s.p1 + base * r

def read_and_print_results(s, n):
	for _ in range(n):
		line = stdin.readline().strip().split()
		p = Vector(int(line[0]), int(line[1]))
		x = project(s, p)
		print('{0:0.10f} {1:0.10f}'.format(x.x, x.y))
(x1, y1, x2, y2) = input().split()
p1 = Point(int(x1), int(y1))
p2 = Point(int(x2), int(y2))
s = Segment(p1, p2)
n = int(input())
read_and_print_results(s, n)


def inner_product(v1, v2):
	return v1.real * v2.real + v1.imag * v2.imag

def projection(a, b):
	return a * inner_product(a, b) / abs(a) ** 2

def solve(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	pro = projection(a, b)
	t = p0 + pro
	return t

def main():
	(x_p0, y_p0, x_p1, y_p1) = map(float, input().split())
	p0 = complex(x_p0, y_p0)
	p1 = complex(x_p1, y_p1)
	q = int(input())
	for _ in range(q):
		p2 = complex(*map(float, input().split()))
		t = solve(p0, p1, p2)
		print('{:.10f} {:.10f}'.format(t.real, t.imag))
main()


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, p):
		return Point(self.x + p.x, self.y + p.y)

	def __sub__(self, p):
		return Point(self.x - p.x, self.y - p.y)

	def __mul__(self, p):
		return Point(self.x * p, self.y * p)

def Dot(a, b):
	return a.x * b.x + a.y * b.y

def Cross(a, b):
	return a.x * b.y - a.y * b.x

def Dis(a, b):
	return math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y))
(x1, y1, x2, y2) = map(int, input().split())
p1 = Point(x1, y1)
p2 = Point(x2, y2)
p1p2_dis = Dis(p1, p2)
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	p = Point(x, y)
	dot_res = Dot(p - p1, p2 - p1)
	len = dot_res / p1p2_dis
	x = (p2 - p1) * (len / p1p2_dis) + p1
	print(x.x, x.y)


import sys
input = sys.stdin.readline
from math import cos, sin, radians, sqrt

def Projection(p1, p2):
	(x1, y1, x2, y2) = p1
	if x1 * x1 + y1 * y1 > x2 * x2 + y2 * y2:
		(x1, y1, x2, y2) = (x2, y2, x1, y1)
	(x3, y3) = p2
	tx = x2 - x1
	ty = y2 - y1
	l = sqrt(tx * tx + ty * ty)
	nx = tx / l
	ny = ty / l
	pl = nx * (x3 - x1) + ny * (y3 - y1)
	return (nx * pl + x1, ny * pl + y1)

def main():
	(x1, y1, x2, y2) = map(int, input().split())
	for i in range(int(input())):
		(x3, y3) = map(int, input().split())
		print('{:.10f} {:.10f}'.format(*Projection((x1, y1, x2, y2), (x3, y3))))
main()


(a, b, c, d) = map(float, input().split())
c -= a
d -= b
for _ in [0] * int(input()):
	(x, y) = map(float, input().split())
	x -= a
	y -= b
	z = (c * x + d * y) / (c * c + d * d)
	print(a + c * z, b + d * z)


from math import sin, cos, atan2

def sgn(x, eps=1e-10):
	if x < -eps:
		return -1
	if -eps <= x <= eps:
		return 0
	if eps < x:
		return 1

class Vector:

	def __init__(self, x=0.0, y=0.0):
		self.x = x
		self.y = y

	def arg(self):
		return atan2(self.y, self.x)

	def norm(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

	def rotate(self, t):
		nx = self.x * cos(t) - self.y * sin(t)
		ny = self.x * sin(t) + self.y * cos(t)
		return Vector(nx, ny)

	def counter(self):
		nx = -self.x
		ny = -self.y
		return Vector(nx, ny)

	def times(self, k):
		nx = self.x * k
		ny = self.y * k
		return Vector(nx, ny)

	def unit(self):
		norm = self.norm()
		nx = self.x / norm
		ny = self.y / norm
		return Vector(nx, ny)

	def normal(self):
		norm = self.norm()
		nx = -self.y / norm
		ny = self.x / norm
		return Vector(nx, ny)

	def add(self, other):
		nx = self.x + other.x
		ny = self.y + other.y
		return Vector(nx, ny)

	def sub(self, other):
		nx = self.x - other.x
		ny = self.y - other.y
		return Vector(nx, ny)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

class Line:

	def __init__(self, bgn=Vector(), end=Vector()):
		self.bgn = bgn
		self.end = end

	def build(self, a, b, c):
		assert sgn(a) != 0 or sgn(b) != 0
		if sgn(b) == 0:
			self.bgn = Vector(-c / a, 0.0)
			self.end = Vector(-c / a, 1.0)
		else:
			self.v = Vector(0, -c / b)
			self.u = Vector(1.0, -(a + b) / b)

	def vec(self):
		return self.end.sub(self.bgn)

	def projection(self, point):
		v = self.vec()
		u = point.sub(self.bgn)
		k = v.dot(u) / v.norm()
		h = v.unit().times(k)
		return self.bgn.add(h)
(xp1, yp1, xp2, yp2) = map(int, input().split())
q = int(input())
p1 = Vector(xp1, yp1)
p2 = Vector(xp2, yp2)
l = Line(p1, p2)
for _ in range(q):
	(x, y) = map(int, input().split())
	p = Vector(x, y)
	proj = l.projection(p)
	print(proj)


(x, y, s, t) = map(float, input().split())
a = int(input())
s -= x
t -= y
while a:
	a -= 1
	(p, q) = map(float, input().split())
	p -= x
	q -= y
	ans_x = s * (q * t + p * s) / (t * t + s * s)
	ans_y = t * (q * t + p * s) / (t * t + s * s)
	print(x + ans_x, y + ans_y)


import sys
from sys import stdin
input = stdin.readline

class Point(object):
	epsilon = 1e-10

	def __init__(self, x=0.0, y=0.0):
		if isinstance(x, tuple):
			self.x = x[0]
			self.y = x[1]
		else:
			self.x = x
			self.y = y

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Point(other * self.x, other * self.y)

	def __truediv__(self, other):
		return Point(other / self.x, other / self.y)

	def __lt__(self, other):
		if self.x == other.x:
			return self.y < other.y
		else:
			return self.x < other.x

	def __eq__(self, other):
		from math import fabs
		if fabs(self.x - other.x) < Point.epsilon and fabs(self.y - other.y) < Point.epsilon:
			return True
		else:
			return False

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		from math import sqrt
		return sqrt(self.norm())

class Vector(Point):

	def __init__(self, x=0.0, y=0.0):
		if isinstance(x, tuple):
			self.x = x[0]
			self.y = x[1]
		elif isinstance(x, Point):
			self.x = x.x
			self.y = x.y
		else:
			self.x = x
			self.y = y

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Vector(other * self.x, other * self.y)

	def __truediv__(self, other):
		return Vector(other / self.x, other / self.y)

	@classmethod
	def dot(cls, a, b):
		return a.x * b.x + a.y * b.y

	@classmethod
	def cross(cls, a, b):
		return a.x * b.y - a.y * b.x

	@classmethod
	def is_orthogonal(cls, a, b):
		return Vector.dot(a, b) == 0.0

	@classmethod
	def is_parallel(cls, a, b):
		return Vector.cross(a, b) == 0.0

class Segment(object):

	def __init__(self, p1=Point(), p2=Point()):
		if isinstance(p1, Point):
			self.p1 = p1
			self.p2 = p2
		elif isinstance(p1, tuple):
			self.p1 = Point(p1[0], p1[1])
			self.p2 = Point(p2[0], p2[1])

	@classmethod
	def is_orthogonal(cls, s1, s2):
		a = Vector(s1.p2 - s1.p1)
		b = Vector(s2.p2 - s2.p1)
		return Vector.is_orthogonal(a, b)

	@classmethod
	def is_parallel(cls, s1, s2):
		a = Vector(s1.p2 - s1.p1)
		b = Vector(s2.p2 - s2.p1)
		return Vector.is_parallel(a, b)

class Line(Segment):
	pass

class Cirle(object):

	def __init__(self, c=Point(), r=0.0):
		self.c = c
		self.r = r

def solve(s, p):
	base = Vector(s.p2 - s.p1)
	a = Vector(p - s.p1)
	r = Vector.dot(a, base)
	r /= base.norm()
	return s.p1 + base * r

def main(args):
	(x_p1, y_p1, x_p2, y_p2) = map(int, input().split())
	q = int(input())
	s = Segment((x_p1, y_p1), (x_p2, y_p2))
	for _ in range(q):
		(x, y) = map(int, input().split())
		p = Point(x, y)
		result = solve(s, p)
		print('{:.10f} {:.10f}'.format(result.x, result.y))
main(sys.argv[1:])


import math

def equals(a, b):
	return abs(a - b) < 1e-10

class Point:

	def __init__(self, x=0, y=0):
		self.x = x
		self.y = y

	def __add__(self, p):
		return Point(self.x + p.x, self.y + p.y)

	def __sub__(self, p):
		return Point(self.x - p.x, self.y - p.y)

	def __mul__(self, a):
		return Point(self.x * a, self.y * a)

	def __rmul__(self, a):
		return self * a

	def __truediv__(self, a):
		return Point(self.x / a, self.y / a)

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return math.sqrt(self.norm())

	def __lt__(self, p):
		if self.x != p.x:
			return self.x < p.x
		else:
			return self.y < p.y

	def __eq__(self, p):
		return equals(self.x, p.x) and equals(self.y, p.y)

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

def dot(a, b):
	return a.x * b.x + a.y * b.y

def cross(a, b):
	return a.x * b.y - a.y * b.x

def project(s, p):
	base = s.p2 - s.p1
	r = dot(p - s.p1, base) / base.norm()
	return s.p1 + base * r
(x1, y1, x2, y2) = [int(v) for v in input().split()]
s = Segment(Point(x1, y1), Point(x2, y2))
q = int(input())
ans = []
for i in range(q):
	(x, y) = [int(v) for v in input().split()]
	p = Point(x, y)
	ans.append(project(s, p))
for v in ans:
	print('{0:.10f} {1:.10f}'.format(v.x, v.y))


import math

class Vector2:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, v):
		return Vector2(self.x + v.x, self.y + v.y)

	def __sub__(self, v):
		return Vector2(self.x - v.x, self.y - v.y)

	def __mul__(self, v):
		return Vector2(self.x * v, self.y * v)

	def __truediv__(self, v):
		return Vector2(self.x / v, self.y / v)

	def __abs__(self):
		return math.sqrt(float(self.x * self.x + self.y * self.y))

	def dot(self, v):
		return self.x * v.x + self.y * v.y

	def cross(self, v):
		return self.x * v.y - self.y * v.x

	def norm(self):
		d = abs(self)
		return Vector2(self.x / d, self.y / d)
(x1, y1, x2, y2) = map(int, input().split())
v12 = Vector2(x2 - x1, y2 - y1).norm()
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	v = Vector2(x - x1, y - y1)
	d = v12.dot(v)
	ans = Vector2(x1 + v12.x * d, y1 + v12.y * d)
	print(f'{ans.x} {ans.y}')


import sys
from itertools import starmap
readline = sys.stdin.readline

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
	p2 = complex(*map(float, readline().split()))
	ap = project(s, p2)
	print(ap.real, ap.imag)


def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def projection(a, b):
	return a * dot(a, b) / abs(a) ** 2

def solve(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	pro = projection(a, b)
	t = p0 + pro
	return t

def main():
	(x0, y0, x1, y1) = map(float, input().split())
	p0 = complex(x0, y0)
	p1 = complex(x1, y1)
	q = int(input())
	for i in range(q):
		p2 = complex(*map(float, input().split()))
		t = solve(p0, p1, p2)
		print('{:.10f} {:.10f}'.format(t.real, t.imag))
main()


import math

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __repr__(self):
		return f'({self.x},{self.y})'

class Segment:

	def __init__(self, x: Point, y: Point):
		self.pt1 = x
		self.pt2 = y
		self.vector = self.pt2 - self.pt1
		self.norm = pow(self.vector.x, 2) + pow(self.vector.y, 2)
		self.abs = math.sqrt(self.norm)

	def dot(self, other):
		return self.vector.x * other.vector.x + self.vector.y * other.vector.y

	def cross(self, other):
		return self.vector.x * other.vector.y - self.vector.y * other.vector.x

	def projection(self, pt: Point) -> Point:
		vec_p1_to_pt = Segment(self.pt1, pt)
		t = self.dot(vec_p1_to_pt) / self.abs
		x = self.pt1.x + t / self.abs * self.vector.x
		y = self.pt1.y + t / self.abs * self.vector.y
		return Point(x, y)

	def __repr__(self):
		return f'{self.pt1},{self.pt2},{self.vector}'

def main():
	(p0_x, p0_y, p1_x, p1_y) = map(int, input().split())
	seg_1 = Segment(Point(p0_x, p0_y), Point(p1_x, p1_y))
	num_query = int(input())
	for i in range(num_query):
		(pt_x, pt_y) = map(int, input().split())
		proj = seg_1.projection(Point(pt_x, pt_y))
		print('{:.10f} {:.10f}'.format(proj.x, proj.y))
	return
main()


def dot(a, b):
	return a[0] * b[0] + a[1] * b[1]

def projection(a, b):
	return [x * dot(a, b) / dot(a, a) for x in a]
(x1, y1, x2, y2) = [int(i) for i in input().split()]
a = [x2 - x1, y2 - y1]
q = int(input())
for i in range(q):
	(x, y) = [int(i) for i in input().split()]
	b = [x - x1, y - y1]
	c = projection(a, b)
	print(c[0] + x1, c[1] + y1)


import math

class Point:
	EPS = 1 << 10

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, other):
		return Point(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Point(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Point(self.x * other, self.y * other)

	def __floordiv__(self, other):
		return Point(self.x / other.x, self.y / other.y)

	def __abs__(self):
		return math.sqrt(self.norm())

	def norm(self):
		return self.x ** 2 + self.y ** 2

	def __eq__(self, other):
		EPS = self.__class__.EPS
		return abs(self.x - other.x) < EPS and abs(self.x - other.x) < EPS

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def isOrthogonal(self, a, b):
		return a.dot(b) == 0.0

	def isParallel(self, a, b):
		return a.cross(b) == 0.0

	def __str__(self):
		return str(self.x) + ' ' + str(self.y)

class Vector(Point):
	pass

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

	def isOrthogonal(s1, s2):
		return (s1.p2 - s1.p1).dot(s2.p2 - s2.p1) == 0.0

	def isParallel(s1, s2):
		return (s1.p2 - s1.p1).cross(s2.p2 - s2.p1) == 0.0

class Line(Segment):
	pass

class Circle:

	def __init__(self, c, r):
		self.c = c
		self.r = r

class Polygon:

	def __init__(self, *points):
		self.points = points

def project(s, p):
	base = s.p2 - s.p1
	r = (p - s.p1).dot(base) / base.norm()
	return s.p1 + base * r
(x1, y1, x2, y2) = map(int, input().split())
(p1, p2) = (Point(x1, y1), Point(x2, y2))
s = Segment(p1, p2)
q = int(input())
for i in range(q):
	p = Point(*map(int, input().split()))
	print(project(s, p))


import sys
from itertools import starmap
readline = sys.stdin.readline

class Segment(object):
	__slots__ = ('fi', 'se')

	def __init__(self, fi, se):
		self.fi = fi
		self.se = se

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return abs(base) ** 2

def project(s, p2):
	base = s.fi - s.se
	r = dot(p2 - s.fi, base) / norm(base)
	return s.fi + base * r
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
	p2 = complex(*map(int, readline().split()))
	ap = project(s, p2)
	print(ap.real, ap.imag)


(sx, sy, ex, ey) = (int(n) for n in input().split(' '))
trial = int(input())
for _ in range(trial):
	(x, y) = (int(n) for n in input().split(' '))
	if sx == ex:
		print(sx, y)
	elif sy == ey:
		print(x, sy)
	else:
		grad = (ey - sy) / (ex - sx)
		y_seg = sy - grad * sx
		per_grad = -1 / grad
		per_y_seg = y - per_grad * x
		ans_x = (y_seg - per_y_seg) / (-1 * (grad - per_grad))
		ans_y = per_grad * ans_x + per_y_seg
		print(ans_x, ans_y)


class Vec2:

	def __init__(self, y, x):
		self.y = y
		self.x = x

	def __add__(self, other):
		assert isinstance(other, Vec2)
		return Vec2(self.y + other.y, self.x + other.x)

	def __sub__(self, other):
		assert isinstance(other, Vec2)
		return Vec2(self.y - other.y, self.x - other.x)

	def __mul__(self, other):
		if isinstance(other, Vec2):
			return self.y * other.y + self.x * other.x
		else:
			return Vec2(self.y * other, self.x * other)

	def __str__(self):
		return str((self.y, self.x))

	def size(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

	def projection(self, vec):
		p = self * vec / self.size() ** 2
		return self * p

def main():
	(x_p1, y_p1, x_p2, y_p2) = map(int, input().split())
	p1 = Vec2(y_p1, x_p1)
	p2 = Vec2(y_p2, x_p2)
	p1p2 = p2 - p1
	q = int(input())
	for _ in range(q):
		(x_q, y_q) = map(int, input().split())
		p1q = Vec2(y_q, x_q) - p1
		p1x = p1p2.projection(p1q)
		x = p1 + p1x
		print(x.x, x.y)
main()


import sys
input = sys.stdin.readline

class Vector:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __add__(self, vec):
		return Vector(self.x + vec.x, self.y + vec.y)

	def __sub__(self, vec):
		return Vector(self.x - vec.x, self.y - vec.y)

	def __mul__(self, sc):
		return Vector(self.x * sc, self.y * sc)

	def __truediv__(self, sc):
		return Vector(self.x / sc, self.y / sc)

	def __iadd__(self, vec):
		self.x += vec.x
		self.y += vec.y
		return self

	def __isub__(self, vec):
		self.x -= vec.x
		self.y -= vec.y
		return self

	def __imul__(self, sc):
		self.x *= sc
		self.y *= sc
		return self

	def __itruediv__(self, sc):
		self.x /= sc
		self.y /= sc
		return self

	def __str__(self):
		return f'{self.x} {self.y}'

	def __eq__(self, vec):
		return self.x == vec.x and self.y == vec.y

	def dot(self, vec):
		return self.x * vec.x + self.y * vec.y

	def abs(self):
		return (self.x * self.x + self.y * self.y) ** 0.5
(x1, y1, x2, y2) = map(int, input().split())
v1 = Vector(x1, y1)
v2 = Vector(x2, y2)
n = v2 - v1
n /= n.abs()
for _ in [0] * int(input()):
	(x, y) = map(int, input().split())
	v = Vector(x, y) - v1
	print(v1 + n * n.dot(v))


def projection(x1, y1, x2, y2, x0, y0):
	if x2 == x1:
		return (x2, y0)
	m = float(y2 - y1) / float(x2 - x1)
	b = y1 - m * x1
	xp = (x0 + m * y0 - m * b) / (1.0 + m * m)
	yp = (m * x0 + m * m * y0 + b) / (1.0 + m * m)
	return (xp, yp)
(x1, y1, x2, y2) = map(float, input().split())
q = int(input())
for _ in range(q):
	(x0, y0) = map(float, input().split())
	ans = projection(x1, y1, x2, y2, x0, y0)
	print(ans[0], ans[1])


pp = list(map(int, input().split()))
n = int(input())

def project(bb, p=pp):
	ans = []
	a = (p[0] - p[2], p[1] - p[3])
	b = (bb[0] - p[0], bb[1] - p[1])
	c = dot(a, b) / length(a) ** 2
	ans += [c * i for i in a]
	print(ans[0] + p[0], ans[1] + p[1])

def length(vector):
	ans = 0
	for i in vector:
		ans += i ** 2
	return ans ** (1 / 2)

def dot(a, b):
	n = len(a)
	if n != len(b):
		return None
	ans = 0
	for (i, j) in zip(a, b):
		ans += i * j
	return ans
for i in range(n):
	b = list(map(int, input().split()))
	project(b)


pt = []
(x1, y1, x2, y2) = map(int, input().split())
q = int(input())
for _ in range(q):
	(xq, yq) = map(int, input().split())
	if x2 - x1 == 0:
		pt.append([x1, yq])
	else:
		a1 = (y2 - y1) / (x2 - x1)
		b1 = y1 - a1 * x1
		if a1 == 0:
			pt.append([xq, y1])
		else:
			a2 = -1 / a1
			b2 = yq - a2 * xq
			x = (b2 - b1) / (a1 - a2)
			y = a1 * x + b1
			pt.append([x, y])
for i in range(q):
	print(pt[i][0], pt[i][1])


EPS = 1e-10

class Point:
	global EPS

	def __init__(self, x=0, y=0):
		self.x = x
		self.y = y

	def __add__(a, b):
		s = a.x + b.x
		t = a.y + b.y
		return Point(s, t)

	def __sub__(a, b):
		s = a.x - b.x
		t = a.y - b.y
		return Point(s, t)

	def __mul__(self, a):
		s = a * self.x
		t = a * self.y
		return Point(s, t)

	def __truediv__(self, a):
		s = self.x / a
		t = self.y / a
		return Point(s, t)

	def norm(self):
		return self.x * self.x + self.y * self.y

	def abs(self):
		return self.norm() ** 0.5

	def __eq__(self, other):
		return abs(self.x - other.y) < self.EPS and abs(self.y - other.y) < self.EPS

	def dot(self, b):
		return self.x * b.x + self.y * b.y

	def cross(self, b):
		return self.x * b.y - self.y * b.x

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

def project(s, p):
	base = s.p2 - s.p1
	hypo = p - s.p1
	r = hypo.dot(base) / base.norm()
	return s.p1 + base * r
nums = list(map(int, input().split()))
s = Segment(Point(nums[0], nums[1]), Point(nums[2], nums[3]))
n = int(input())
for i in range(n):
	nums = list(map(int, input().split()))
	p = Point(nums[0], nums[1])
	x = project(s, p)
	print(x.x, x.y)


(x1, y1, x2, y2) = map(int, input().split())
q = int(input())
p1p2 = complex(x2 - x1, y2 - y1)
d2_p1p2 = abs(p1p2) ** 2
conj_p1p2 = p1p2.conjugate()
while q:
	q -= 1
	(x0, y0) = map(int, input().split())
	p1p0 = complex(x0 - x1, y0 - y1)
	t = (conj_p1p2 * p1p0).real / d2_p1p2
	print(x1 + p1p2.real * t, y1 + p1p2.imag * t)


import array
from fractions import Fraction
import math
import os
import sys

class Vec(object):

	def __init__(self, x, y):
		self.x = x
		self.y = y
		super().__init__()

	def __add__(self, other):
		return Vec(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vec(self.x - other.x, self.y - other.y)

	def __mul__(self, scalar):
		return Vec(self.x * scalar, self.y * scalar)

	def __truediv__(self, scalar):
		return Vec(self.x / scalar, self.y / scalar)

	def __iadd__(self, other):
		self.x += other.x
		self.y += other.y
		return self

	def __isub__(self, other):
		self.x -= other.x
		self.y -= other.y
		return self

	def __imul__(self, scalar):
		self.x *= scalar
		self.y *= scalar
		return self

	def __idiv__(self, scalar):
		self.x /= scalar
		self.y /= scalar
		return self

	def __neg__(self):
		return Vec(-self.x, -self.y)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def cross(self, other):
		return self.x * other.y - self.y * other.x

	def abs2(self):
		return self.x * self.x + self.y * self.y

	def __abs__(self):
		return math.sqrt(float(self.abs2()))

	def __str__(self):
		return '({}, {})'.format(self.x, self.y)

def main():
	(x1, y1, x2, y2) = read_ints()
	Q = read_int()
	for _ in range(Q):
		(x, y) = read_ints()
		print(*solve(Vec(x1, y1), Vec(x2, y2), Vec(x, y)))

def solve(u, v, a):
	v -= u
	a -= u
	f = Fraction(v.dot(a), v.abs2())
	v *= f
	v += u
	return (float(v.x), float(v.y))
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)
main()


def project(x, y):
	base = [x2 - x1, y2 - y1]
	hypo = [x - x1, y - y1]
	r = (base[0] * hypo[0] + base[1] * hypo[1]) / (base[0] ** 2 + base[1] ** 2)
	return (x1 + base[0] * r, y1 + base[1] * r)
(x1, y1, x2, y2) = map(int, input().split())
q = int(input())
for i in range(q):
	(x, y) = map(int, input().split())
	print(*project(x, y))


def dot(a, b):
	return a.real * b.real + a.imag * b.imag
(x1, y1, x2, y2) = map(int, input().split())
p1 = x1 + y1 * 1j
p2 = x2 + y2 * 1j
l = p2 - p1
l_norm = dot(l, l)
q = int(input())
for (x3, y3) in (map(int, input().split()) for _ in [0] * q):
	p3 = x3 + y3 * 1j
	a = p3 - p1
	k = dot(a, l) / l_norm
	projection_vector = k * l
	print(x1 + projection_vector.real, y1 + projection_vector.imag)


import sys
from itertools import starmap
readline = sys.stdin.readline
(p0, p1) = starmap(complex, zip(*[map(int, readline().split())] * 2))
n = int(readline())

def cross(a, b):
	return a.real * b.imag - a.imag * b.real

def dot(a, b):
	return a.real * b.real + a.imag * b.imag

def norm(base):
	return base.real * base.real + base.imag * base.imag

def project(p0, p1, p2):
	base = p0 - p1
	r = dot(p2 - p0, base) / norm(base)
	return p0 + base * r
for _ in [0] * n:
	p2 = complex(*[int(i) for i in readline().split()])
	ap = project(p0, p1, p2)
	print(ap.real, ap.imag)


EPS = 10 ** (-9)

def is_equal(a, b):
	return abs(a - b) < EPS

def norm(v, i):
	import math
	ret = 0
	n = len(v)
	for j in range(n):
		ret += abs(v[j]) ** i
	return math.pow(ret, 1 / i)

class Vector(list):

	def __add__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) + other.__getitem__(i)
		return self.__class__(ret)

	def __radd__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = other.__getitem__(i) + super().__getitem__(i)
		return self.__class__(ret)

	def __iadd__(self, other):
		n = len(self)
		for i in range(n):
			self[i] += other.__getitem__(i)
		return self

	def __sub__(self, others):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) - others.__getitem__(i)
		return self.__class__(ret)

	def __iadd__(self, other):
		n = len(self)
		for i in range(n):
			self[i] -= other.__getitem__(i)
		return self

	def __rsub__(self, others):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = others.__getitem__(i) - super().__getitem__(i)
		return self.__class__(ret)

	def __mul__(self, other):
		n = len(self)
		if isinstance(other, list):
			ret = 0
			for i in range(n):
				ret += super().__getitem__(i) * other.__getitem__(i)
			return ret
		else:
			ret = [0] * n
			for i in range(n):
				ret[i] = super().__getitem__(i) * other
			return self.__class__(ret)

	def __rmul__(self, other):
		n = len(self)
		if isinstance(other, list):
			ret = 0
			for i in range(n):
				ret += super().__getitem__(i) * other.__getitem__(i)
			return ret
		else:
			ret = [0] * n
			for i in range(n):
				ret[i] = super().__getitem__(i) * other
			return self.__class__(ret)

	def __truediv__(self, other):
		n = len(self)
		ret = [0] * n
		for i in range(n):
			ret[i] = super().__getitem__(i) / other
		return self.__class__(ret)

	def norm(self, i):
		return norm(self, i)

	def __pow__(self, other):
		n = len(self)
		ret = [0] * 3
		x = self[:]
		y = other[:]
		if n == 2:
			x.append(0)
			y.append(0)
		if n == 2 or n == 3:
			for i in range(3):
				(ret[0], ret[1], ret[2]) = (x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0])
			ret = Vector(ret)
			if n == 2:
				return ret.norm(2)
			else:
				return ret

class Segment:

	def __init__(self, v1, v2):
		self.v1 = v1
		self.v2 = v2

class Line(Segment):

	def get_unit_vec(self):
		return (self.v2 - self.v1) / norm(self.v2 - self.v1, 2)

	def projection(self, vector):
		unit_vec = self.get_unit_vec()
		t = unit_vec * (vector - self.v1)
		return self.v1 + t * unit_vec

	def is_vertical(self, other):
		return is_equal(0, self.get_unit_vec() * other.get_unit_vec())

	def is_horizontal(self, other):
		return is_equal(0, self.get_unit_vec() ** other.get_unit_vec())
tmp = list(map(int, input().split()))
p1 = Vector(tmp[:2])
p2 = Vector(tmp[2:])
L = Line(p1, p2)
q = int(input())
for i in range(q):
	p = Vector(map(int, input().split()))
	print(*L.projection(p))


from decimal import Decimal as D
(a, s, d, f) = map(D, input().split())
h = [d - a, f - s]
leh = ((d - a) ** 2 + (f - s) ** 2) ** D('0.5')
for i in range(int(input())):
	(x, y) = map(D, input().split())
	co = (x - a) * h[0] / leh + (y - s) * h[1] / leh
	print(a + h[0] * co / leh, s + h[1] * co / leh)


(xp1, yp1, xp2, yp2) = map(int, input().split())
q = int(input())
xp = complex(xp2 - xp1, yp2 - yp1)
x1 = complex(xp1, yp1)
for _ in range(q):
	(x, y) = map(int, input().split())
	xpi = complex(x - xp1, y - yp1)
	dot = xp.real * xpi.real + xp.imag * xpi.imag
	ans = x1 + dot * xp / abs(xp) ** 2
	print('{:.9f} {:.9f}'.format(ans.real, ans.imag))


def inner_product(v1, v2):
	return v1.real * v2.real + v1.imag * v2.imag

def projection(a, b):
	return a * inner_product(a, b) / abs(a) ** 2

def solve(p0, p1, p2):
	a = p1 - p0
	b = p2 - p0
	pro = projection(a, b)
	t = p0 + pro
	return t

def main():
	(x_p0, y_p0, x_p1, y_p1) = map(float, input().split())
	p0 = complex(x_p0, y_p0)
	p1 = complex(x_p1, y_p1)
	q = int(input())
	for _ in range(q):
		p2 = complex(*map(float, input().split()))
		t = solve(p0, p1, p2)
		print('{:.10f} {:.10f}'.format(t.real, t.imag))
main()