#define MYDEBUG
//
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
using namespace std;
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
	out << "{" << p.first << "," << p.second << "}";
	return out;
}
template<typename T>
inline string toString(const T &a) {
	ostringstream oss;
	oss << a;
	return oss.str();
}
static const double EPS = 1e-10;
bool equals(double a, double b) {
	return a > b ? a - b < EPS : b - a < EPS;
}
class Point {
public:
	double x, y;
	Point(double inx = 0.0, double iny = 0.0) :
			x(inx), y(iny) {
	}
	Point operator+(const Point &p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator-(const Point &p) {
		return Point(x - p.x, y - p.y);
	}
	Point operator*(const double k) {
		return Point(x * k, y * k);
	}
	Point operator/(const double k) {
		return Point(x / k, y / k);
	}
	Point operator=(const Point &p) {
		x = p.x;
		y = p.y;
		return *this;
	}
	bool operator<(const Point &p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator==(const Point &p) const {
		return equals(x, p.x) && equals(y, p.y);
	}
	double norm() {
		return x * x + y * y;
	}
	double abs() {
		return sqrt(norm());
	}
};
typedef Point Vector;
class Segment {
public:
	Point p1, p2;
	Vector getvector() {
		return p2 - p1;
	}
};
typedef Segment Line;
class Circle {
public:
	Point c;
	double r;
	Circle(Point inc = Point(), double inr = 0.0) :
			c(inc), r(inr) {
	}
};
typedef vector<Point> Polygon;
double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}
double norm(Vector a) {
	return a.x * a.x + a.y * a.y;
}
double abs(Vector a) {
	return sqrt(norm(a));
}
const int CCW = 1;
const int CW = 1;
const int on_segment = 2;
const int online_back = 2;
const int online_front = -2;
bool is_orthogonal(Vector a, Vector b) {
	return equals(dot(a, b), 0.0);
}
bool is_orthogonal(Point a1, Point a2, Point b1, Point b2) {
	return is_orthogonal(a1 - a2, b1 - b2);
}
bool is_orthogonal(Segment s1, Segment s2) {
	return equals(dot(s1.getvector(), s2.getvector()), 0.0);
}
bool is_parallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}
bool is_parallel(Point a1, Point a2, Point b1, Point b2) {
	return is_parallel(a1 - a2, b1 - b2);
}
bool is_parallel(Segment s1, Segment s2) {
	return equals(cross(s1.getvector(), s2.getvector()), 0.0);
}

Point project(Segment s, Point p) {
	Vector base = s.getvector();
	double r = dot(p - s.p1, base) / norm(base);
	return s.p1 + base * r;
}
Point reflect(Segment s, Point p) {
	return project(s, p) * 2.0 - p; //p + (project(s, p) - p) * 2.0
}
double getdistance(Point a, Point b) {
	return abs(a - b);
}
double getdistancelp(Line l, Point p) {
	double s = abs(cross(l.p2 - l.p1, p - l.p1));
	return s / abs(l.getvector());
}

void solve() {
	Point p1, p2;
	cin >> p1.x >> p1.y;
	cin >> p2.x >> p2.y;
	Line l;
	l.p1 = p1;
	l.p2 = p2;
	int q;
	cin >> q;
	rep(i,0,q)
	{
		Point pq;
		cin >> pq.x >> pq.y;
		Point pj = project(l, pq);
		printf("%.10lf %.10lf\n", pj.x, pj.y);
	}
}
int main() {
	solve();
}

Measured memory_bytes: 3296