#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double dot(double x1, double y1, double x2, double y2){
    return(x1 * x2 + y1 * y2);
}

double scalar(double x, double y){
    return(sqrt(x * x + y * y));
}

int main(void){
    int xp1, yp1, xp2, yp2, *xp, *yp;
    int q, i;
    float error = 1.0E-8, *x, *y, a;
    
    scanf("%d %d %d %d", &xp1, &yp1, &xp2, &yp2);
    scanf("%d", &q);
    
    xp = (int *)malloc(sizeof(int) * q);
    yp = (int *)malloc(sizeof(int) * q);
    x = (float *)malloc(sizeof(float) * q);
    y = (float *)malloc(sizeof(float) * q);
    
    for(i = 0; i < q; i ++){
        scanf("%d %d", &xp[i], &yp[i]);
    }
    
    for(i = 0; i < q; i ++){
        a = dot(xp2 - xp1, yp2 - yp1, xp1 - xp[i], yp1 - yp[i]) / (scalar(xp2 - xp1, yp2 - yp1) * scalar(xp2 - xp1, yp2 - yp1));
        x[i] = xp1 + a * (xp1 - xp2);
        y[i] = yp1 + a * (yp1 - yp2);
        
        printf("%f %f\n", x[i], y[i]);
    }
    
    free(xp);
    free(yp);
    free(x);
    free(y);
    
    return 0;
}