#include <iostream>
#include <cstdio>
#define EPS 0.00000001
using namespace std;

int main(){
 
    double x1, y1, x2, y2, x0, y0, dx, dy, m, X, Y;
    int q;
    cin >> x1 >> y1 >> x2 >> y2 >> q;
    dx = x1 - x2;
    dy = y1 - y2;
    while (q--){
      cin >> x0 >> y0;
      X=(dx*dx*x0+dy*dy*x1-dx*dy*(y1-y0))/(dx*dx+dy*dy);
      Y = !(-EPS<=dx && dx<=EPS) ? Y=dy/dx*(X-x1)+y1 : Y=y0;
  		printf("%.8lf %.8lf\n",X,Y);
    }
}
