#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <math.h>
#include <iterator>
using namespace std;
int main() {
	while (true) {
		int n;
		scanf("%d", &n);
		if (n == 0) goto end;
		for (int fu = 0;fu < n;++fu) {
			int x[2] = {}, y[2] = {}, z[2] = {}, w[2] = {};
			int ki = 0,kj = 0,ji = 0, kazu = 0, i = 0, j = 0, k = 0, i2 = 0, ij = 0, ik = 0, j2 = 0, jk = 0, k2 = 0;
				for (int q = 0;q < 2;++q) {
				scanf("%d%d%d%d", &x[q], &y[q], &z[q], &w[q]);
			}
				kazu = x[0] * x[1];
				i = (x[0] * y[1]);
				j = (x[0] * z[1]);
				k = (x[0] * w[1]);
				i += (y[0] * x[1]);
				i2 += (y[0] * y[1]);
				ij += (y[0] * z[1]);
				ik += (y[0] * w[1]);
				j += (z[0] * x[1]);
				ji += (z[0] * y[1]);
				j2 += (z[0] * z[1]);
				jk += (z[0] * w[1]);
				k += (w[0] * x[1]);
				ki += (w[0] * y[1]);
				kj += (w[0] * z[1]);
				k2 += (w[0] * w[1]);
				kazu -= (i2+j2+k2);
				k += ij;
				j -= ik;
				k -= ji;
				i += jk;
				j += ki;
				i -= kj;
				printf("%d %d %d %d\n", kazu, i, j, k);
		}
	}
end:;
}
