#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;

static constexpr double PI = 3.1415926535897932;
struct angle {
	double r;
	angle() :r(0) {}
	angle(double r_) :r(arr(std::fmod(r_, 2.0 * PI) + 2.0 * PI)) {}
	static double arr(const double &o) { return o < 2.0 * PI - eps ? o : o - 2.0 * PI; }
	static angle make(const double &o) { angle ret;ret.r = o;return ret; }
	const angle operator+(const angle &o)const { return make(arr(r + o.r)); }
	const angle operator-(const angle &o)const { return make(arr(r - o.r + 2.0 * PI)); }
	const angle operator*(const double &o)const { return angle(r * o); }
	const angle operator/(const double &o)const { return angle(r / o); }
	angle &operator+=(const angle &o) { return *this = *this + o; }
	angle &operator-=(const angle &o) { return *this = *this - o; }
	angle &operator*=(const double &o) { return *this = *this * o; }
	angle &operator/=(const double &o) { return *this = *this / o; }
	const angle operator~()const { return make(arr(3.0 * PI - r)); }
	const angle operator-()const { return make(arr(2.0 * PI - r)); }
	const bool operator==(const angle &o)const { return std::abs(r - o.r) <= eps; }
	const bool operator!=(const angle &o)const { return std::abs(r - o.r) > eps; }
	const bool operator< (const angle &o)const { return r <  o.r; }
	const bool operator<=(const angle &o)const { return r <= o.r; }
	const bool operator> (const angle &o)const { return r >  o.r; }
	const bool operator>=(const angle &o)const { return r >= o.r; }
	explicit operator bool()const { return r > eps; }
	explicit operator double()const { return r; }
	const double sin()const { return std::sin(r); }
	const double cos()const { return std::cos(r); }

	const double degree()const { return r*(180.0 / PI); }
	const double ratio()const { return r / (2.0 * PI); }
private:
	static constexpr double eps = 0.0000001;
};
angle operator"" _deg(long double x) { return angle(x*(PI / 180.0)); }
angle operator"" _rat(long double x) { return angle(x * 2.0 * PI); }
angle operator"" _rad(long double x) { return angle(x); }
struct pvec {
	static constexpr double eps = 0.0000000000001;
	double x, y;
	pvec() :x(0), y(0) {}
	pvec(double x_, double y_) :x(x_), y(y_) {}
	pvec(double abs_, angle r) :x(abs_*r.cos()), y(abs_*r.sin()) {}
	const pvec operator+(const pvec &o)const { return pvec(x + o.x, y + o.y); }
	const pvec operator-(const pvec &o)const { return pvec(x - o.x, y - o.y); }
	const pvec operator*(const pvec &o)const { return pvec(x*o.x - y*o.y, x*o.y + y*o.x); }
	const pvec operator/(const pvec &o)const { return pvec(x*o.x + y*o.y, y*o.x - x*o.y) / abs2(); }
	const pvec operator*(const double &o)const { return pvec(x * o, y * o); }
	const pvec operator/(const double &o)const { return pvec(x / o, y / o); }
	pvec &operator+=(const pvec &o) { return *this = *this + o; }
	pvec &operator-=(const pvec &o) { return *this = *this - o; }
	pvec &operator*=(const pvec &o) { return *this = *this * o; }
	pvec &operator/=(const pvec &o) { return *this = *this / o; }
	pvec &operator*=(const double &o) { return *this = *this * o; }
	pvec &operator/=(const double &o) { return *this = *this / o; }

	const pvec operator+()const { return *this; }
	const pvec operator-()const { return pvec(-x, -y); }
	const pvec operator~()const { return pvec(x, -y); }

	explicit operator bool()const { return std::abs(x) > eps || std::abs(y) > eps; }
	const bool operator==(const pvec &o)const { return std::abs(x - o.x) <= eps&&std::abs(y - o.y) <= eps; }
	const bool operator!=(const pvec &o)const { return std::abs(x - o.x) > eps || std::abs(y - o.y) > eps; }

	const double abs()const { return mysqrt(abs2()); }
	const double abs2()const { return x*x + y*y; }
	const angle arg()const {
		if (x > eps) return angle(std::atan(y / x));
		if (x < eps) return angle(std::atan(y / x) + PI);
		return angle();
	}
	static const double dot(const pvec &l, const pvec &r) { return l.x*r.x + l.y*r.y; }
	static const double cross(const pvec &l, const pvec &r) { return l.x*r.y - l.y*r.x; }
	const pvec dir()const { return *this / abs(); }

	static const bool C_x(const pvec &l, const pvec &r) {
		if (l.x != r.x) return l.x < r.x;
		return l.y < r.y;
	}

	friend std::istream &operator>>(std::istream &is, pvec &o) {
		double x_, y_;is >> x_ >> y_;o = pvec(x_, y_);return (is);
	}
	friend std::ostream &operator<<(std::ostream &os, const pvec &o) {
		return os << o.x << " " << o.y;
	}
private:
	static const double mysqrt(const double &x) {
		double h = 0.5*x;
		std::uint_fast64_t t = 0x5FE6EB50C7B537AAl
			- (*(std::uint_fast64_t*)&x >> 1);
		double r = *(double*)&t;
		r *= 1.5 - h*r*r;r *= 1.5 - h*r*r;
		r *= 1.5 - h*r*r;r *= 1.5 - h*r*r;
		return r*x;
	}
};

int main(void) {
	//std::ios::sync_with_stdio(false);
	//std::cin.tie(0);
	pvec o, d;
	std::cin >> o >> d;
	d = (d - o).dir();
	uint32 q;
	std::cin >> q;
	pvec p;
	while (q--) {
		std::cin >> p;
		p -= o;
		p = d*pvec::dot(p, d);
		p += o;
		printf("%6.10f %6.10f\n", p.x, p.y);
	}
	return 0;
}


Measured memory_bytes: 3300