#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        while (n--) {
            int a[4], b[4], c[4];

            for (int i = 0; i < 4; i++) {
                cin >> a[i];
                c[i] = 0;
            }
            for (int i = 0; i < 4; i++) 
                cin >> b[i];

            c[0] = a[0] * b[0] - a[1] * b[1] - a[2] * b[2] - a[3] * b[3];
            c[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] - a[3] * b[2];
            c[2] = a[0] * b[2] - a[1] * b[3] + a[2] * b[0] + a[3] * b[1];
            c[3] = a[0] * b[3] + a[1] * b[2] - a[2] * b[1] + a[3] * b[0];
            
            for (int i = 0; i < 3; i++)
                cout << c[i] << " ";
            cout << c[3] << endl;
        }
    }
    

    return 0;
}