#include <stdio.h>
 
int main(void)
{
 int xp1, yp1, xp2, yp2;
 int q;
 int xp, yp;
 int i = 1;
 double x, y;
 double k;
 
 scanf("%d%d", &xp1, &yp1);
 scanf("%d%d", &xp2, &yp2);
 scanf("%d", &q);
 
 do {
 scanf("%d%d", &xp, &yp);
 
 k = ((xp2 - xp1) * (xp2 - xp1) +(yp2 - yp1) * (yp2 - yp1))(xp * (xp2 - xp1) + yp * (yp2 - yp1));
 x = (xp2 - xp1) / k;
 y = (yp2 - yp1) / k;
 
 printf("%.10f %.10f\n", x, y);
 
 i = i++;
 } while(i < q);
 
 return 0;
 
}