#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

typedef complex<double> Point;
typedef Point Vector;
//???????????¨????§???????
struct Segment{ Point p1, p2; };
//??´????????¨????§???????
typedef Segment Line;
//????§???¢?????¨????§???????
typedef vector<Point> Polygon;

namespace std{
    bool operator < (const Point &a, const Point &b){
        return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
    }
    bool operator == (const Point &a, const Point &b){
        return a.real() == b.real() && a.imag() == b.imag();
    }
}

class Circle{
public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

// ?¨±???????????????
#define EPS (1e-10)
// 2??????????????????????????????????????????
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2??????????????????????????????????????????
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )

// ????????????a?????¶??????????±???????
//double length = abs(a);

// 2???a,b???????????¢????±???????
//double distance = abs(a-b);

/*
// ????????????a?????????????????????????±???????
Point b = a / abs(a);

// ????????????a?????????????????????n1,n2????±???????
Point n1 = a * Point(0, 1);
Point n2 = a * Point(0, -1);
*/

// ?????? (dot product) : a???b = |a||b|cos??
double dot(Point a, Point b) {
    return (a.real() * b.real() + a.imag() * b.imag());
}

// ?????? (cross product) : a??b = |a||b|sin??
double cross(Point a, Point b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

// 2??´????????´????????? : a??\b <=> dot(a, b) = 0
int isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
    return EQ( dot(a1-a2, b1-b2), 0.0 );
}

// 2??´?????????????????? : a//b <=> cross(a, b) = 0
int isParallel(Point a1, Point a2, Point b1, Point b2) {
    return EQ( cross(a1-a2, b1-b2), 0.0 );
}

// ???c?????´???a,b????????????????????????
int isPointOnLine(Point a, Point b, Point c) {
    return EQ( cross(b-a, c-a), 0.0 );
}

// ???a,b???????????´?????¨???c??¨????????¢
double distanceLPoint(Point a, Point b, Point c) {
    return abs(cross(b-a, c-a)) / abs(b-a);
}

// ???a,b???????????¨??????????????¨???c??¨????????¢
double distanceLsPoint(Point a, Point b, Point c) {
    if ( dot(b-a, c-a) < EPS ) return abs(c-a);
    if ( dot(a-b, c-b) < EPS ) return abs(c-b);
    return abs(cross(b-a, c-a)) / abs(b-a);
}

// a1,a2???????????¨??????????????¨b1,b2???????????¨???????????????????????????
int isIntersectedLs(Point a1, Point a2, Point b1, Point b2) {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
        ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
}

// a1,a2???????????¨??????????????¨b1,b2???????????¨??????????????????????¨????
Point intersectionLs(Point a1, Point a2, Point b1, Point b2) {
    Point b = b2-b1;
    double d1 = abs(cross(b, a1-b1));
    double d2 = abs(cross(b, a2-b1));
    double t = d1 / (d1 + d2);

    return a1 + (a2-a1) * t;
}

// a1,a2???????????´?????¨b1,b2???????????´??????????????????
int isIntersectedL(Point a1, Point a2, Point b1, Point b2) {
    return !EQ( cross(a1-a2, b1-b2), 0.0 );
}

// a1,a2???????????´?????¨b1,b2???????????´?????????????¨????
Point intersectionL(Point a1, Point a2, Point b1, Point b2) {
    Point a = a2 - a1; Point b = b2 - b1;
    return a1 + a * cross(b, b1-a1) / cross(b, a);
}

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

int main(){
    Point p1, p2, p;
    Segment p12;
    double a, b, c, d;
    int q;
    cin >> a >> b >> c >> d >> q;
    p1 = Point(a, b);
    p2 = Point(c, d);
    p12.p1 = p1;
    p12.p2 = p2;
    rep(i,q){
        double a, b;
        cin >> a >> b;
        p = Point(a, b);
        Point ans = project(p12, p);
        cout << fixed << setprecision(10) << ans.real() << ' ' << ans.imag() << endl;
    }

}

Measured memory_bytes: 3360