#include <stdio.h>          // printf(), scanf()

int
main(int argc, char** argv)
{
	double sx, sy;
	double tx, ty;
	int q;
	int x, y;
	int x1, y1, x2, y2;
	int i;

	scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
	sx = x1, sy = y1;
	tx = x2, ty = y2;

	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &x, &y);
		double px = x, py = y;

		double bx = tx - sx, by = ty - sy;
		double ax = px - sx, ay = py - sy;
		double r = (ax * bx + ay * by) / (bx * bx + by * by);
		double cx = sx + bx * r, cy = sy + by * r;

		printf("%.10f %.10f\n", cx, cy);
	}

	return 0;
}