#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
struct Point{
Point(double arg_x,double arg_y){
x = arg_x;
y = arg_y;
}
Point(){
x = y = 0.0;
}
Point operator + (Point p){ return Point(x+p.x,y+p.y); }
Point operator - (Point p){ return Point(x-p.x,y-p.y);}
Point operator * (double a){ return Point(a*x,a*y); }
Point operator / (double a){ return Point(x/a,y/a); }
double abs(){ return sqrt(norm()); }
double norm(){ return x*x + y*y; }
bool operator<(const Point &p) const{
return x != p.x? x < p.x: y < p.y;
}
bool operator == (const Point &p) const{
return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
}
/*
void debug(){
printf("(%.3lf,%.3lf)\n",x,y);
}*/
double x,y;
};
typedef Point Vector;
typedef vector<Point> Polygon;
struct Line{
Line(){
}
Line(Point a,Point b){
p[0] = a;
p[1] = b;
}
/*void outPut(){
printf("(%.3lf,%.3lf)-(%.3lf,%.3lf)\n",p[0].x,p[0].y,p[1].x,p[1].y);
}*/
Point p[2];
};
double norm(Vector a){
return a.x*a.x+a.y*a.y;
}
double abs(Vector a){
return sqrt(norm(a));
}
double dot(Vector a,Vector b){
return a.x*b.x + a.y*b.y;
}
double cross(Vector a,Vector b){
return a.x*b.y-a.y*b.x;
}
Point project(Line l,Point p){
Vector base = l.p[1]-l.p[0];
double r = dot(p-l.p[0],base)/norm(base);
return l.p[0]+base*r;
}
int main(){
Line base_line;
scanf("%lf %lf %lf %lf",&base_line.p[0].x,&base_line.p[0].y,&base_line.p[1].x,&base_line.p[1].y);
Point tmp_p;
int num_query;
scanf("%d",&num_query);
for(int loop = 0; loop < num_query; loop++){
scanf("%lf %lf",&tmp_p.x,&tmp_p.y);
Point proj_p = project(base_line,tmp_p);
printf("%.10lf %.10lf\n",proj_p.x,proj_p.y);
}
return 0;
}