#include<stdio.h>
#include<math.h>
struct points {
	double x;
	double y;
};
int main(void) {
	
	
	struct points eigenvector;
	int p1x, p1y, p2x, p2y, px, py;
		scanf("%d,%d", &p1x, &p1y, &p2x, &p2y);
		struct points p1, p2;
		p1.x = p1x;
		p1.y = p1y;
		
		p2.x = p2x;
		p2.y = p2y;
		double length = sqrt((p1.x - p2.x)*(p1.x - p2.x)+ (p1.y - p2.y)*(p1.y - p2.y));
		eigenvector.x = (p1.x - p2.x) / length;
		eigenvector.y = (p1.y - p2.y) / length;
		int q;
		scanf("%d",  &q);
		
		for (int i = 0; i < q; ++i) {
			scanf("%d,%d", &px, &py);
			double  returnqx, returnqy;
			printf("%.10f,%.10f", p1.x+(px - p1.x)*eigenvector.x, p1.y + (py - p1.y)*eigenvector.y);

		}

	return 0;
}