    #include<stdio.h>
    int main()
    {
        double x1,x2,x3,y1,y2,y3,q,m1,c1,c2,X,Y,m2,i;
        scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
        scanf("%lf",&q);
        for(i=0;i<q;i++)
        {
            scanf("%lf %lf",&x3,&y3);
            if(x1==x2)
            {
                X=x2;
                Y=y3;
            }
            else if(y1==y2)
            {
                Y=y1;
                X=x3;
            }
            else
            {
                m1=(y1-y2)/(x1-x2);
                c1=y1-m1*x1;
                m2=-1/m1;
                c2=y3-m2*x3;
                X=(c2-c1)/(m1-m2);
                Y=m2*X+c2;}
            printf("%.10lf %.10lf\n",X,Y);
        }
    	return 0;
    }

  // ALHAMDULLIAH



