#include <stdio.h>
#include <math.h>
#define y1 y11111

double x1,y1,x2,y2;
int main(){
	scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
	x2-=x1;
	y2-=y1;
	double len=hypot(x2,y2);
	x2/=len;
	y2/=len;
	int q;
	scanf("%d",&q);
	while(q--){
		double x,y;
		scanf("%lf%lf",&x,&y);
		x-=x1;
		y-=y1;
		double r=(x*x2+y*y2);
		printf("%.9f %.9f\n",x1+r*x2,y1+r*y2);
	}
}
