#include <stdio.h>

void pv(double ax, double ay, double bx, double by, 
        double px, double py, double ans[]);

int main(void)
{
    double ax, ay, bx, by;
    int n, i;
    double tmpx, tmpy;
    double ans[2];

    scanf("%lf%lf%lf%lf%d", &ax, &ay, &bx, &by, &n);

    for (i = 0; i < n; i++) {
        scanf("%lf%lf", &tmpx, &tmpy);
        pv(ax, ay, bx, by, tmpx, tmpy, ans);
        printf("%.10lf %.10lf\n", ans[0], ans[1]);
    }
    return 0;
}

void pv(double ax, double ay, double bx, double by, 
        double px, double py, double ans[]) {
    //*find the projection point ans of p onto a,b *//
    double x1 = bx-ax, x2 = px-ax, y1 = by-ay, y2 = py-ay;
    ans[0] = 1.0 * (x1*x2+y1*y2)/(x1*x1+y1*y1)*x1 + ax;
    ans[1] = 1.0 * (x1*x2+y1*y2)/(x1*x1+y1*y1)*y1 + ay;
}