#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

void func(int N){
	int a,b,c,d,e,f,g,h;
	int ans_a,ans_b,ans_c,ans_d;

	for(int i = 0; i < N; i++){
		scanf("%d %d %d %d %d %d %d %d",&a,&b,&c,&d,&e,&f,&g,&h);

		ans_a = a*e-b*f-c*g-d*h;
		ans_b = a*f+b*e+c*h-d*g;
		ans_c = a*g-b*h+c*e+d*f;
		ans_d = a*h+b*g-c*f+d*e;

		printf("%d %d %d %d\n",ans_a,ans_b,ans_c,ans_d);
	}
}

int main(){

	int N;
	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

    return 0;
}