#include<iostream>
using namespace std;
int main() {
	int n; while (cin >> n)
		if (!n)return 0;
	else for (int i = 0; i < n; i++){
		int x1, x2, x3, y1, y2, y3, z1, z2, z3, w1, w2, w3;
		cin >> 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;
		cout << x3 << ' ' << y3 << ' ' << z3 << ' ' << w3 << endl;
	}
}