#include <iostream>
#include <string>
using namespace std;

int main() {
    int n,x1,y1,z1,w1,x2,y2,z2,w2;
    while (cin>>n, n) {
        for (int i=0; i<n; ++i) {
            cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;
            cout << (x1 * x2) - (y1 * y2) - (z1 * z2) - (w1 * w2) << " "
                 << (x1 * y2) + (x2 * y1) + (z1 * w2) - (w1 * z2) << " "
                 << (x1 * z2) + (z1 * x2) + (w1 * y2) - (y1 * w2) << " "
                 << (x1 * w2) + (w1 * x2) + (y1 * z2) - (z1 * y2) << endl;
        }
    }
    return 0;
}