#include<bits/stdc++.h>
#define endl '\n'
#define INF (1 << 21)
const int MOD = 1000000009;
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int x[2], y[2], z[2], w[2];
  int ax, ay, az, aw;

  cin >> n;
  while(n != 0){
    for(int i = 0;i < n;i++){
      cin >> x[0] >> y[0] >> z[0] >> w[0];
      cin >> x[1] >> y[1] >> z[1] >> w[1];

      ax = x[0] * x[1] + (-1) * y[0] * y[1] + (-1) * z[0] * z[1] + (-1) * w[0] * w[1];
      
      ay = x[0] * y[1] + y[0] * x[1] + z[0] * w[1] + (-1) * w[0] * z[1];

      az = x[0] * z[1] + (-1) * y[0] * w[1] + z[0] * x[1] + w[0] * y[1];

      aw = x[0] * w[1] + y[0] * z[1] + (-1) * z[0] * y[1] + w[0] * x[1];
      
      cout << ax << ' ' << ay << ' ' << az << ' ' << aw << endl;
    }
    cin >> n;
  }
  return 0;
}


