#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;
typedef pair<int,int> P;
int main() {
	int n;
	while(scanf("%d",&n),n) {
		double x1,y1,z1,w1,x2,y2,z2,w2;
		for(int i=0;i<n;i++) {
			scanf("%lf %lf %lf %lf",&x1,&y1,&z1,&w1);
			scanf("%lf %lf %lf %lf",&x2,&y2,&z2,&w2);
			double x3,y3,z3,w3;
			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;
			cout<<x3<<' '<<y3<<' '<<z3<<' '<<w3<<endl;
		}
	}
}