#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> prod(const vector<ll> &a, const vector<ll> &b){
  vector<ll> ret(4);
  ret[0] = a[0]*b[0]-a[1]*b[1]-a[2]*b[2]-a[3]*b[3];
  ret[1] = a[0]*b[1]+a[1]*b[0]+a[2]*b[3]-a[3]*b[2];
  ret[2] = a[0]*b[2]-a[1]*b[3]+a[2]*b[0]+a[3]*b[1];
  ret[3] = a[0]*b[3]+a[1]*b[2]-a[2]*b[1]+a[3]*b[0];
  return ret;
}

int main(){
  int n;
  while(cin >> n, n){
    for(int i = 0; i < n; ++i){
      vector<ll> a(4), b(4);
      for(int i = 0; i < 4; ++i) cin >> a[i];
      for(int i = 0; i < 4; ++i) cin >> b[i];
      vector<ll> ans = prod(a,b);
      cout << ans[0];
      for(int i = 1; i < 4; ++i)  cout << " " << ans[i];
      cout << endl;
    }
  }
}

