#include <stdio.h>
#include <math.h>

typedef struct Point {
	double x;
	double y;
} Point;

typedef struct Vector {
	struct Point point;
	double size;
} Vector;

Point VectorAddition(Point, Point, int);
double Vectormultiplication(Point, Point);
double VectorSize(Point);

int main(void) {

	Point point1, point2, point3, ans;
	Vector vector1, vector2;
	int q, i;

	scanf("%lf %lf %lf %lf %d", &point1.x, &point1.y, &point2.x, &point2.y, &q);

	vector1.point.x = point2.x - point1.x;
	vector1.point.y = point2.y - point1.y;
	vector1.size = sqrt(pow(vector1.point.x, 2) + pow(vector1.point.y, 2));

	for (i = 0; i < q; i++) {

		scanf("%lf %lf", &point3.x, &point3.y);

		vector2.point = VectorAddition(point1, point3, 2);
		vector2.size = VectorSize(vector2.point);

		ans.x = Vectormultiplication(vector1.point, vector2.point) / pow(vector1.size, 2) * vector1.point.x;
		ans.y = Vectormultiplication(vector1.point, vector2.point) / pow(vector1.size, 2) * vector1.point.y;

		printf("%lf %lf\n", ans.x, ans.y);
	}

	return 0;
}

Point VectorAddition(Point p1, Point p2, int sign) {
	Point point;
	switch (sign) {
	case 1:
		point.x = p2.x + p1.x;
		point.y = p2.y + p1.y;
		break;
	case 2:
		point.x = p2.x - p1.x;
		point.y = p2.y - p1.y;
		break;
	}
	return point;
}

double Vectormultiplication(Point p1, Point p2) {
	Point point;
	double i;
	point.x = p1.x * p2.x;
	point.y = p1.y * p2.y;
	i = point.x + point.y;
	return i;
}

double VectorSize(Point p) {
	return sqrt(pow(p.x, 2) + pow(p.y, 2));
}