
#include<iostream>
#include<string>
#include<algorithm>
#include<sstream>
#include <functional>
#include<cmath>
#include<map>
using namespace std;


int main(){
	int n;
	while(cin>>n,n){
		while(n--){
	int a,b,c,d,e,f,g,h;
	cin>>a>>b>>c>>d>>e>>f>>g>>h;
	int w=0,x=0,y=0,z=0;
	w=(a*e)-(b*f)-(c*g)-(d*h);
	x=b*e+a*f+c*h-d*g;
	y=a*g+c*e+d*f-b*h;
	z=a*h+d*e+b*g-c*f;
	cout<<w<<" "<<x<<" "<<y<<" "<<z<<endl;
	}
	}
}