
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

int main(){
	PT a, b;
	cin >> a >> b;
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		PT p;
		cin >> p;
		PT img = proj(a, b, p);
		cout << img.real() << ' ' << img.imag() << '\n';
	}
	return 0;
}
