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

//?????????
#pragma region MACRO 
#define putans(x)  std::cerr << "answer: " ; cout << (x) << endl
#define dputans(x) std::cerr << "answer: "; cout << setprecision(13) << (double)(x) << endl
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define RREP(i,a,n) for(int i=(int)(n-1); i>= a; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) begin((a)),end((a))
#define mp make_pair
#define exist(container, n) ((container).find((n)) != (container).end())
#define equals(a,b) (fabs((a)-(b)) < EPS)
#ifdef _DEBUG //???????????????????????????????????????????????????
std::ifstream ifs("data.txt");
#define put ifs >>
#else //?????£????????????????????§?????????????????????
#define put cin >>
#endif
#pragma endregion

//???????????°??????????????´
#pragma region CODING_SUPPORT
#define dbg(var0) { std::cerr << ( #var0 ) << "=" << ( var0 ) << endl; }
#define dbg2(var0, var1) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg(var1); }
#define dbg3(var0, var1, var2) { std::cerr << ( #var0 ) << "=" << ( var0 ) << ", "; dbg2(var1, var2); }
#define dbgArray(a,n) {std::cerr << (#a) << "=";  rep(i,n){std::cerr <<(a[i])<<",";} cerr<<endl;} 
#ifndef _DEBUG
#define dbg1 {}
#define dbg2 {}
#define dbg3 {}
#define dbgArray {}
#endif 
#pragma endregion 
//typedef????????????????????????????¶????????????§?????????
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii; typedef pair<string, string> pss; typedef pair<int, string>pis;
typedef vector<string> vs; typedef vector<int> vi;
#pragma endregion
//??????????????°(???????????????????????§??????)
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e9)
#pragma endregion

class Point {//????????????????????????
public:
	double x, y;
	Point(double x = 0, double y = 0) : x(x), y(y) {}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x - p.x, y - p.y); }
	Point operator * (double a) { return Point(x * a, y * a); }
	double operator * (Point p) { return dot(p); }
	Point operator / (double a) { return Point(x / a, y / a); }

	double abs() { return sqrt(norm()); }
	double norm() { return x*x + y*y; }

	bool operator < (const Point &p) const {return  x != p.x ? x < p.x : y < p.y;}
	bool operator == (const Point &p) const {return  fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;}
	//???????????????
	double dot(Point p) {return x * p.x + y * p.y;}
	double cross(Point p) { return x * p.y - y * p.x; }

};
class Circle {
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0) :c(c), r(r) {}
};
struct Segment {//??????
	Point p1, p2;
};

typedef Point Vector;
typedef Segment Line;//??´???
typedef vector<Point> Polygon;

//??´????????????
bool isOrthogonal(Vector a, Vector b) { return equals(a*b, 0.0); }
bool isParallel(Vector a, Vector b) { return equals(a.cross(b), 0.0); }

//??????s???????????????p????°???±
Point projection(Segment s, Point p) {
	Vector base = s.p2 - s.p1;
	double r = (p - s.p1).dot( base) / base.norm();
	return s.p1 + base*r;
}


int main() {
	double xp1, yp1, xp2, yp2; put xp1 >> yp1 >> xp2 >> yp2;
	Segment s;
	s.p1 = Point(xp1, yp1);
	s.p2 = Point(xp2, yp2);

	int n; put n;
	rep(i, n) {
		Point p;
		put p.x >> p.y;
		Point prj = projection(s, p);
		cout << setprecision(13) << prj.x << " " << prj.y << endl;
	}
	return 0;
}

/*
#define i(x) int x; scanf("%d",&x);
#define l(x) ll x; scanf("%lld",&x);
#define d(x) double  x; scanf("%lf",&x);
*/
//??????????£?????????°???
//https://www23.atwiki.jp/akitaicpc/pages/65.html

Measured memory_bytes: 3272