#include<stdio.h>
main()
{
	long double a, b, c, n, i, w, x, p, q, x1, x2, y1, y2;
	scanf("%llf%llf%llf%llf", &x1, &y1, &x2, &y2);
	a=y1-y2;
	b=x2-x1;
	c=x1*y2-y1*x2;
	scanf("%llf", &n);
	for (i=1; i<=n; i++)
	{
		scanf("%llf%llf", &w, &x);
		p=((2*a*(a*x1+b*y1+c))/(a*a+b*b))+x1;
		q=((2*b*(a*x1+b*y1+c))/(a*a+b*b))+y1;
		printf("%.9llf %.9llf\n", p, q);
	}
}
