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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int a,b,c,d;
  scanf("%d%d%d%d",&a,&b,&c,&d);
  int p=c-a;
  int q=d-b;
  double norm=p*p+q*q;
  int query;
  scanf("%d",&query);
  while(query--){
    int x,y;
    scanf("%d%d",&x,&y);
    x-=a;
    y-=b;
    int innerNorm=p*x+q*y;
    double xx=a+p*innerNorm/norm;
    double yy=b+q*innerNorm/norm;
    printf("%.6lf %.6lf\n",xx,yy);
  }
}

int main(void){
  run();
  return 0;
}

