#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 : array<Point, 2> {
	Segment(){}
	Segment(const Point &p1, const Point &p2){
		(*this)[0] = p1;
		(*this)[1] = p2;
	}
};

struct Line : array<Point, 2> {
	Line(){}
	Line(const Point &p1, const Point &p2){
		(*this)[0] = p1;
		(*this)[1] = 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[1] - l1[0], l2[1] - l2[0])) == 0;
}

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

template <typename L>
Point project(const L &l, const Point &p){
	Point t = l[1] - l[0];
	Double r = dot(p - l[0], t) / norm(t);
	return l[0] + 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[1] - l1[0], l2[0] - l1[0])) == 0;
}

bool intersect(const Line &l, const Segment &s){
	return sign(cross(l[1] - l[0], s[0] - l[0])) * sign(cross(l[1] - l[0], s[1] - l[0])) <= 0;
}

bool intersect(const Line &l, const Point &p){
	return sign(cross(l[0] - p, l[1] - p)) == 0;
}

bool intersect(const Segment &s1, const Segment &s2){
	return ccw(s1[0], s1[1], s2[0]) * ccw(s1[0], s1[1], s2[1]) <= 0
		&& ccw(s2[0], s2[1], s1[0]) * ccw(s2[0], s2[1], s1[1]) <= 0;
}

bool intersect(const Segment &s, const Point &p){
	return ccw(s[0], s[1], p) == 0;
}

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

Measured memory_bytes: 1300