#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<functional>
#include<vector>
#include<queue>
#include<complex>
using namespace std;
#define f(i,n) for(int i=0;i<(int)n;i++)
#define MOD 1000000009
#define MIN (1e-10)
typedef complex<double> P;
bool EQ(P a, P b){
	if (abs(a.real() - b.real()) < MIN&&abs(a.imag() - b.imag()) < MIN)return true;
	else return false;
}
double dot(P a, P b){
	return{ a.real()*b.real() + a.imag()*b.imag() };
}
double cross(P a, P b){
	return{ a.real()*b.imag() - a.imag()*b.real() };
}
P insec(P a1, P a2, P b1, P b2){
	P a, b;
	a = a2 - a1;
	b = b2 - b1;
	return a1 + (a*cross(b, b1 - a1) / cross(b, a));
}
void print(double x,int k){
	if (x < 0){
		printf("-");
		x = -x;
	}
	printf("%d.", (int)x);
	x = x - (double)(int)x;
	f(i, k){
		x = x * 10;
		printf("%d", (int)x);
		x = x - (double)(int)x;
	}
	return;
}

int main(void){
	P a, b, c;
	P d, e, f;
	double x, y;
	int n;
	scanf("%lf %lf", &x, &y);
	a = P(x, y);
	scanf("%lf %lf", &x, &y);
	b = P(x, y);
	f = (b - a)*P(0, 1);
	scanf("%d", &n);
	f(i, n){
		scanf("%lf %lf", &x, &y);
	c = P(x, y);
	d = c + f;
	e = insec(a, b, c, d);
	print(e.real(),10);
	printf(" ");
	print(e.imag(),10);
	printf("\n");
	}
	return 0;
}