#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i,x1,x2,x3,z1,z2,z3,w1,w2,w3,y1,y2,y3;

	while(1)	{
		scanf("%d",&n);
		if(n==0)	break;
		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=y1*x2+x1*y2-w1*z2+z1*w2;
			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);
		}
	}
	return 0;
}
