#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <functional>
#include <queue>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main() {
  for (;;) {
    int n;
    cin >> n;
    if (!n) return 0;
    for (int i = 0; i < n; i++) {
      int a[8];
      for (int j = 0; j < 8; j++)
        cin >> a[j];
      cout << a[0]*a[4]-a[1]*a[5]-a[2]*a[6]-a[3]*a[7] << ' '
           << a[0]*a[5]+a[1]*a[4]+a[2]*a[7]-a[3]*a[6] << ' '
           << a[0]*a[6]-a[1]*a[7]+a[2]*a[4]+a[3]*a[5] << ' '
           << a[0]*a[7]+a[1]*a[6]-a[2]*a[5]+a[3]*a[4] << endl;
    }
  }
}