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