#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;
const double EPS=1e-9;
const double PI=3.141592653589793238;//18 ragham

bool Equal(double d1,double d2)
{ return fabs(d1-d2)<EPS;}

struct line{double a,b,c;};
struct vec
{
  double x,y;
  vec(double _x=0,double _y=0)
  {x=_x;  y=_y;}
};
  
struct point_i
{
  int x,y;
  point_i(int _x=0,int _y=0){x=_x;y=_y;}
};
struct point
{
  double x,y;
  point(double _x=0,double _y=0){x=_x;y=_y;}
  bool operator < (point other)
  {  
    if(fabs(x-other.x)<EPS)
      return y<other.y;
    return x<other.x;}
  bool operator == (point other)
  {return (fabs(x-other.x)<EPS) && (fabs(y-other.y)<EPS) ;}
  
  
};
double Hypot(double dx,double dy)
{
  return sqrt(dx*dx+dy*dy);
}
double Distance(point p1,point p2)
{
  return hypot(p1.x-p2.x,p1.y-p2.y);
}
double DEG_to_RAD(double theta)
{
  return theta*PI/180;
}
point rotate(point p, double theta)//theta is degree
{
  
  //rotation matrixR(theta) = [cos(theta) - sin(theta)]
  //                          [sin(theta) + cos(theta)]
  //usage: [x'] = R(theta)* [x]
  //       [y']             [y]
  double rad=DEG_to_RAD(theta);
  return point(p.x * cos(rad) - p.x * sin(rad) ,
	       p.y * sin(rad) + p.y * cos(rad)  );
}
void PointsToLine(point p1,point p2,line *l)
{
  if(p1.x==p2.x) // vertical line handled here
    { l->a=1.0;   l->b= 0.0 ; l->c=-p1.x;}
  else
    {
      l->a=-(double)(p1.y-p2.y)/(p1.x-p2.x);
      l->b=1.0;
      l->c=-(double)(l->a * p1.x) - (l->b*p1.y);
    }
}
bool AreParallel(line l1,line l2)
{
  return Equal(l1.a,l2.a) && Equal(l1.b,l2.b);
}
bool AreSame(line l1,line l2)
{
  return AreParallel(l1,l2) && Equal(l1.c,l2.c);
}
bool AreIntersect(line l1,line l2,point *p)//TO BE CHECKED (mine)
{
  if(AreSame(l1,l2))
    return false;
  if(AreParallel(l1,l2))
    return false;

  //solving
  double delta=(double)l1.a*l2.b - l1.b*l2.a;
  if(Equal(delta,0))//this if should never be true because lines are't parallel
    return false;
  p->x= (double)(l1.c*l2.b-l2.c*l1.b) / delta;
  p->y= (double)(l1.a*l2.c-l2.a*l1.c) / delta;
  return true;
}
vec ToVector(point p1,point p2)
{
  return vec(p2.x-p1.x,p2.y-p1.y);
}
vec ScaleVector(vec v, double s) // v*=s
{
  return vec(v.x*s,v.y*s);
}
point Translate(point p,vec move)//moves point p in direction of vector move
{
  return point(p.x+move.x , p.y + move.y);
}
double Dot(double x1,double y1 ,double x2,double y2)
{ return x1*x2+y1*y2;};
double Cross(point p,point q,point r)
{
  return (r.x-q.x)*(p.y-q.y)-(r.y-q.y)*(p.x-q.x);
}
bool Collinear(point p,point q,point r)
{
  return Equal(Cross(p,q,r),0);
}
//returns true if point r is on the left side of line pq
bool CCW(point p,point q,point r)
{
   //can be modified to accept collinear ( >0 instead of >EPS )
  if(Cross(p,q,r) > EPS)
    return true;
  return false;
}

//returns the distance from p to line AB
// A and B must be different
//closest point is in *c
double DistToLine(point p,point A,point B,point *c)
{// formula : c= A+ (p-A).(A-B)/|B-A|*(B-A)
  double scale= (double)
    ((p.x-A.x)*(B.x-A.x)+(p.y-A.y)*(B.y-A.y))/
    ((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y));
  c->x= A.x + scale*(B.x - A.x);
  c->y= A.y + scale*(B.y - A.y);
  
  return Distance(p,*c);
}
double DistToLineSegment(point p,point A,point B,point *c)
{
  if((B.x-A.x) * (p.x-A.x)+ (B.y-A.y)*(p.y-A.y) <EPS)
    { c->x=A.x ; c->y= A.y;
      return Distance(p,A);}//closer to A
 
  if((A.x-B.x) * (p.x-B.x)+ (A.y-B.y)*(p.y-B.y) <EPS)
    { c->x=B.x ; c->y= B.y;
      return Distance(p,B);}//closer to B

  return DistToLine(p,A,B,c);
  
}


///*****************### End of Library ###*******************///





point p0,p1,p2;
int n;

void input()
{
  int x,y;
  cin>>x>>y;
  p0=point(x,y);
  
  cin>>x>>y;
  p1=point(x,y);
  cin>>n; 
 
 
}

int main()
{
  input();
  for(int i=1;i<=n;i++)
    {
      int x,y;
  cin>>x>>y;
  p2=point(x,y);
  point ans;
  DistToLine(p2,p0,p1,&ans);
  cout<<fixed;
  cout<<setprecision(9);
  cout<<ans.x<<" "<<ans.y<<endl;
  
    }
  return 0;
}

Measured memory_bytes: 1260