#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
#define X real()
#define Y imag()
ld dot(pt u,pt v){
	return (u.X*v.X+v.Y*u.Y);
}
int main(){
	cout<<fixed<<setprecision(12);
	ld x,y; 
	ld xx,yy;
	ld xxx,yyy;
	cin>>x>>y;
	cin>>xx>>yy;
	pt a = {x,y};
	pt b = {xx,yy};
	int q; 
	cin>>q;
	while(q--){
		cin>>xxx>>yyy;
		pt c = {xxx,yyy};
		pt m = a+(b-a)*dot(c-a,b-a)/dot(b-a,b-a);
		cout<<m.X<<" "<<m.Y<<endl;
	}
	return 0;
}

