#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

int main(){
    while(1){
        int n; cin>>n;
        if(n == 0) return 0;
        for(int i=0; i<n; i++){
            ll x1, y1, z1, w1, x2, y2, z2, w2;
            cin>>x1>>y1>>z1>>w1>>x2>>y2>>z2>>w2;

            ll x3 = x1 * x2 - y1 * y2 - z1 * z2 - w1 * w2;
            ll y3 = x1 * y2 + y1 * x2 + z1 * w2 - w1 * z2;
            ll z3 = x1 * z2 - y1 * w2 + z1 * x2 + w1 * y2;
            ll w3 = x1 * w2 + y1 * z2 - z1 * y2 + w1 * x2;

            cout << x3 << " " << y3 << " " << z3 << " " << w3 << endl;
        }
    }
}
