#include<iostream>
using namespace std;

int main(){
	int n;
	while(cin >> n && n){
		while(n--){
			int A[4],B[4];
			cin >> A[0] >> A[1] >> A[2] >> A[3];
			cin >> B[0] >> B[1] >> B[2] >> B[3];
			int ans[4] = {0};
			for(int i=0;i<4;i++){
				for(int j=0;j<4;j++){
					if(i == 0) ans[j] += A[i]*B[j];
					else if(j == 0) ans[i] += A[i]*B[j];
					else if(i == 1 && j == 2) ans[3] += A[i]*B[j];
					else if(i == 2 && j == 1) ans[3] += -(A[i]*B[j]);
					else if(i == 3 && j == 1) ans[2] += A[i]*B[j];
					else if(i == 1 && j == 3) ans[2] += -(A[i]*B[j]);
					else if(i == 2 && j == 3) ans[1] += A[i]*B[j];
					else if(i == 3 && j == 2) ans[1] += -(A[i]*B[j]);
					else ans[0] += -(A[i]*B[j]);
				}
			}
			bool flg = false;
			for(int i=0;i<4;i++){
				if(flg) cout << " ";
				else flg = true;
				cout << ans[i];
			}
			cout << endl;
		}
	}
}