#include <iostream>
using namespace std;

int main(){
    int a,b,c,d,e,f,g,h,n;
    while(cin >> n,n){
    	for(int i = 0;i < n;++i){
        	cin >> a >> b >> c >> d >> e >> f >> g >> h;
        	cout << (a*e - b*f - c*g - d*h) << " " << (a*f + b*e + c*h - d*g) << " " << (a*g - b*h + c*e + d*f) << " " << (a*h + b*g - c*f + d*e) << endl; 	
        }
    }
    return 0;
}