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

class point {
public:
	int x, y;
	point() {}
	point( int x_, int y_ ) :x(x_), y(y_) {}
	point operator -( point p ) { return point( x - p.x, y - p.y ); } 
};

int main()
{
	point vp[2];
	cin >> vp[0].x >> vp[0].y >> vp[1].x >> vp[1].y;
	point base = vp[1] - vp[0];
	double norm = base.x * base.x + base.y * base.y;
	int q;
	cin >> q;
	for( int i = 0; i < q; i++ ) {
		point p;
		cin >> p.x >> p.y;

		p = p - vp[0];
		double dot = p.x * base.x + p.y * base.y;
		double x = vp[0].x + base.x * dot / norm;
		double y = vp[0].y + base.y * dot / norm;
		cout << fixed << setprecision(10) << x << " " << y << endl;
	}
}

