#include <iostream>
#include <iomanip>
#include <cmath>

typedef long double ld;

ld dissq(double x1, double y1, double x2, double y2)
{
	return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}

int main()
{
	ld x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	int q; std::cin >> q;
	for (int i=0; i<q; i++) {
		ld x0, y0;
		std::cin >> x0 >> y0;
		ld s = (dissq(x0,y0,x1,y1) + dissq(x1,y1,x2,y2) - dissq(x0,y0,x2,y2)) / (2.0 * dissq(x1,y1,x2,y2));
		ld x = (1.0 - s) * x1 + s * x2;
		ld y = (1.0 - s) * y1 + s * y2;
		std::cout << std::setprecision(8) << std::fixed << x << " " << y << std::endl;
	}
	return 0;
}

