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

typedef double Double;

const Double EPS = 1e-8;
const Double PI = acos((Double)-1.0);

int sign(Double a){
	if (abs(a) < EPS) return 0;
	if (a < 0.0) return -1;
	return 1;
}

bool eq(Double a, Double b){
	return sign(a - b) == 0;
}

bool neq(Double a, Double b){
	return sign(a - b) != 0;
}

bool lt(Double a, Double b){
	return sign(a - b) == -1;
}

bool leq(Double a, Double b){
	return sign(a - b) <= 0;
}

bool gt(Double a, Double b){
	return sign(a - b) == 1;
}

bool geq(Double a, Double b){
	return sign(a - b) >= 0;
}

Double sq(Double a){
	return a * a;
}

struct Point {
	Double x, y;
	
	Point(){}
	Point(Double x, Double y) : x(x), y(y){}
	
	bool operator < (const Point &rhs) const { 
		return x != rhs.x ? x < rhs.x : y < rhs.y;
	}
	
	Point operator + (const Point &rhs) const {
		return Point(x + rhs.x, y + rhs.y);
	}
	
	Point operator - (const Point &rhs) const {
		return Point(x - rhs.x, y - rhs.y);
	}
	
	Point operator * (const Point &rhs) const {
		return Point(x * rhs.x - y * rhs.y, x * rhs.y + y * rhs.x);
	}
	
	Point operator * (Double rhs) const {
		return Point(x * rhs, y * rhs);
	}
	
	Point operator / (Double rhs) const {
		return Point(x / rhs, y / rhs);
	}
	
	Point& operator += (const Point &rhs) {
		return *this = *this + rhs;
	}
	
	Point& operator -= (const Point &rhs) {
		return *this = *this - rhs;
	}
};

Point operator * (Double lhs, const Point &rhs){
	return rhs * lhs;
}

Point operator / (Double lhs, const Point &rhs){
	return rhs * lhs;
}

struct Segment {
	Point p1, p2;
	
	Segment(){}
	Segment(const Point &p1, const Point &p2) : p1(p1), p2(p2){}
};

struct Line {
	Point p1, p2;
	
	Line(){}
	Line(const Point &p1, const Point &p2) : p1(p1), p2(p2){}
};

struct Circle {
	Point p;
	Double r;
	
	Circle(){}
	Circle(const Point &p, Double r) : p(p), r(r){}
};

typedef vector<Point> Polygon;

Double norm(const Point &p){
	return sq(p.x) + sq(p.y);
}

Double abs(const Point &p){
	return sqrt(norm(p));
}

Double arg(const Point &p){
	return atan2(p.y, p.x);
}

Point polar(Double r, Double t){
	return Point(cos(t) * r, sin(t) * r);
}

Double dot(const Point &a, const Point &b){
	return a.x * b.x + a.y * b.y;
}

Double cross(const Point &a, const Point &b){
	return a.x * b.y - a.y * b.x;
}

int ccw(const Point &p0, const Point &p1, const Point &p2){
	Point a = p1 - p0, b = p2 - p0;
	if (sign(cross(a, b)) == 1) return 1;
	if (sign(cross(a, b)) == -1) return -1;
	if (sign(dot(a, b)) == -1) return 2;
	if (lt(norm(a), norm(b))) return -2;
	return 0;
}

template <typename L1, typename L2>
bool orthogonal(const L1 &l1, const L2 &l2){
	return sign(dot(l1.p2 - l1.p1, l2.p2 - l2.p1)) == 0;
}

template <typename L1, typename L2>
bool parallel(const L1 &l1, const L2 &l2){
	return sign(cross(l1.p2 - l1.p1, l2.p2 - l2.p1)) == 0;
}

template <typename L>
Point project(const L &l, const Point &p){
	Point t = l.p2 - l.p1;
	Double r = dot(p - l.p1, t) / norm(t);
	return l.p1 + t * r;
}

template <typename L>
Point reflect(const L &l, const Point &p){
	return p + (project(l, p) - p) * Double(2.0);
}

bool intersect(const Line &l1, const Line &l2){
	if (!parallel(l1, l2)) return true;
	return sign(cross(l1.p2 - l1.p1, l2.p1 - l1.p1)) == 0;
}

bool intersect(const Line &l, const Segment &s){
	return sign(cross(l.p2 - l.p1, s.p1 - l.p1)) * sign(cross(l.p2 - l.p1, s.p2 - l.p1)) <= 0;
}

bool intersect(const Line &l, const Point &p){
	return sign(cross(l.p1 - p, l.p2 - p)) == 0;
}

bool intersect(const Segment &s1, const Segment &s2){
	return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0
		&& ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}

bool intersect(const Segment &s, const Point &p){
	return ccw(s.p1, s.p2, p) == 0;
}

int main()
{
	cout << fixed << setprecision(20);
	
	Line l;
	Point p;
	int q;
	
	cin >> l.p1.x >> l.p1.y >> l.p2.x >> l.p2.y >> q;
	while (q--){
		cin >> p.x >> p.y;
		
		Point pr = project(l, p);
		cout << pr.x << " " << pr.y << endl;
	}
}

Measured memory_bytes: 1300