#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	while (cin >> n, n) {
		for (int j = 0; j < n; j++) {
			vector<int>a(4), b(4), c(4);
			for (int i = 0; i < 4; i++)cin >> a[i];
			for (int i = 0; i < 4; i++)cin >> b[i];
			c[0] = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
			c[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
			c[2] = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
			c[3] = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
			for (int i = 0; i < 4; i++) {
				if (i)cout << " ";

				cout << c[i];
			}
			cout << endl;
		}
	}
	return 0;
}