#include <iostream>

int main()
{
	int N;
	int X1,Y1,Z1,W1,X2,Y2,Z2,W2,aX,aY,aZ,aW;
	std::cin>>N;
	while(N){
		for(int i=0;i<N;i++){
			std::cin>>X1>>Y1>>Z1>>W1>>X2>>Y2>>Z2>>W2;
			aX=X1*X2-Y1*Y2-Z1*Z2-W1*W2;
			aY=X1*Y2+Y1*X2+Z1*W2-W1*Z2;
			aZ=X1*Z2-Y1*W2+Z1*X2+W1*Y2;
			aW=X1*W2+Y1*Z2-Z1*Y2+W1*X2;
			std::cout<<aX<<" "<<aY<<" "<<aZ<<" "<<aW<<std::endl;
		}
		std::cin>>N;
	}
}