#include <iostream>
using namespace std;

class Quaternion {
public:
    int x_, y_, z_, w_;

    Quaternion(int x, int y, int z, int w) {
        x_ = x;
        y_ = y;
        z_ = z;
        w_ = w;
    }

    friend Quaternion operator* (const Quaternion &q1, const Quaternion &q2) {
        return Quaternion(q1.x_ * q2.x_ - q1.y_ * q2.y_ - q1.z_ * q2.z_ - q1.w_ * q2.w_,
                          q1.x_ * q2.y_ + q1.y_ * q2.x_ + q1.z_ * q2.w_ - q1.w_ * q2.z_,
                          q1.x_ * q2.z_ - q1.y_ * q2.w_ + q1.z_ * q2.x_ + q1.w_ * q2.y_,
                          q1.x_ * q2.w_ + q1.y_ * q2.z_ - q1.z_ * q2.y_ + q1.w_ * q2.x_);
    }

    friend ostream& operator<< (ostream &os, const Quaternion &q) {
        return (os << q.x_ << " " << q.y_ << " " << q.z_ << " " << q.w_);
    }
};

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