/*
w2sc
2019/12/19
17:09:09
*/
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
using namespace std;
double sqr(double x){return x*x;}
struct point{
    double x,y;
    point(){}
    point(double xx,double yy){x=xx,y=yy;}
}A,B,P;
typedef point vec;
vec operator +(vec x,vec y){return vec(x.x+y.x,x.y+y.y);}
vec operator -(vec x,vec y){return vec(x.x-y.x,x.y-y.y);}
vec operator *(double x,vec y){return vec(x*y.x,x*y.y);}
struct line{
    point A,B;
    line(){}
    line(point AA,point BB){A=AA,B=BB;}
    double len()
    {
        return sqrt(sqr(A.x-B.x)+sqr(A.y-B.y));
    }
}a,b;
double operator *(vec p1,vec p2)
{return p1.x*p2.x+p1.y*p2.y;}
int q;
int main()
{
    double x,y;
    scanf("%lf%lf",&x,&y);
    A=point(x,y);
    scanf("%lf%lf",&x,&y);
    B=point(x,y);
    a=line(A,B);
    scanf("%d",&q);
    while(q--)
    {
        scanf("%lf%lf",&x,&y);
        P=point(x,y);
        b=line(A,P);
        point ans=A+((a.B-a.A)*(b.B-b.A))/a.len()/a.len()*(a.B-a.A);
        printf("%.15f %.15f\n",ans.x,ans.y);
    }
    return 0;
}

