#include <iostream>
using namespace std;

#define N 4
#define X 0
#define Y 1
#define Z 2
#define W 3

int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (!n)
		{
			return 0;
		}

		for (int i=0; i<n; i++)
		{
			int val1[N], val2[N];
			for (int j=0; j<N; j++)
			{
				cin >> val1[j];
			}
			for (int j=0; j<N; j++)
			{
				cin >> val2[j];
			}

			int ans[N];

			ans[X] = val1[X]*val2[X]
					 -val1[Y]*val2[Y]
					 -val1[Z]*val2[Z]
					 -val1[W]*val2[W];

			ans[Y] = val1[X]*val2[Y]
					 +val1[Y]*val2[X]
					 +val1[Z]*val2[W]
					 -val1[W]*val2[Z];

			ans[Z] = val1[X]*val2[Z]
					 -val1[Y]*val2[W]
					 +val1[Z]*val2[X]
					 +val1[W]*val2[Y];

			ans[W] = val1[X]*val2[W]
					 +val1[Y]*val2[Z]
					 -val1[Z]*val2[Y]
					 +val1[W]*val2[X];

			cout << ans[X] << ' '
				 << ans[Y] << ' '
				 << ans[Z] << ' '
				 << ans[W] << '\n';
		}
	}
}