#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, a, b, c, d, e, f, g, h;
  while (cin >> n, n) {
    while (n--) {
      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 << "\n";
    }
  }
}
