#include<bits/stdc++.h>
#define lb long double 
using namespace std;
struct Po{lb x,y;}p1,p2,x;
int t;
void get(Po &x){scanf("%Lf %Lf",&x.x,&x.y);}
Po operator *(Po x,lb y){return (Po){x.x*y,x.y*y};}
Po operator +(Po x,Po y){return (Po){x.x+y.x,x.y+y.y};}
Po operator -(Po x,Po y){return (Po){x.x-y.x,x.y-y.y};}
lb operator *(Po x,Po y){return x.x*y.x+x.y*y.y;}
lb l2(Po x){return x.x*x.x+x.y*x.y;}
int main(){
	get(p1);get(p2);
	Po np=p2-p1;
	scanf("%d",&t);
	while (t--){
		get(x);
		Po nx=np*((np*(x-p1))/l2(np));
		x=p1+nx;
		printf("%.10Lf %.10Lf\n",x.x,x.y);
	}
	return 0;
}
