#include<stdio.h>
int main(void)
{
	int n;
	int x1,x2,x3;
	int y1,y2,y3;
	int z1,z2,z3;
	int w1,w2,w3;
	int i,j;
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			scanf("%d %d %d %d %d %d %d %d",&x1,&y1,&z1,&w1,&x2,&y2,&z2,&w2);
			x3=x1*x2-y1*y2-z1*z2-w1*w2;
			y3=x1*y2+y1*x2+z1*w2-w1*z2;
			z3=x1*z2-y1*w2+z1*x2+w1*y2;
			w3=x1*w2+y1*z2-z1*y2+w1*x2;
			printf("%d %d %d %d\n",x3,y3,z3,w3);
		}
		scanf("%d",&n);
	}
	return 0;
}