#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const double EPS = 1e-8;

struct Vector {
    double x, y;
    Vector(double x, double y) : x(x), y(y) {
    }
};

typedef Vector Point;

Vector operator-(const Vector& a, const Vector& b) {
    return Vector(a.x - b.x, a.y - b.y);
}

Vector operator+(const Vector& a, const Vector& b) {
    return Vector(a.x + b.x, a.y + b.y);
}

Vector operator*(const Vector& a, const double p) {
    return Vector(a.x * p, a.y * p);
}

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

Vector project(Point a, Point b, Point p) {
    Vector v = b - a;
    double t = dot(p - a, v)/dot(v, v);
    return a + v * t;
    
}

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    Point a(x1, y1);
    Point b(x2, y2);
    
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        double x, y;
        cin >> x >> y;
        Vector ans = project(a, b, Point(x, y));
        cout << setprecision(8) <<fixed << ans.x << " " << ans.y << endl;
    }
    
    return 0;
}