#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,p) for(int i=(a);i<(p);i++)
#define rrep(i,a,p) for(int i=(p)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

int a[4][4] = {
	{ 0,1,2,3 },
	{ 1,0,3,2 },
	{ 2,3,0,1 },
	{ 3,2,1,0 }
};
int b[4][4] = {
	{ 1,1,1,1 },
	{ 1,-1,1,-1 },
	{ 1,-1,-1,1 },
	{ 1,1,-1,-1 }
};
signed main() {
	for (int n; cin >> n&&n;) {
		rep(i, 0, n) {
			int p[4], q[4];
			rep(j, 0, 4)cin >> p[j];
			rep(j, 0, 4)cin >> q[j];

			int ans[4] = {};
			rep(j, 0, 4)rep(k, 0, 4) {
				ans[a[j][k]] += b[j][k] * p[j] * q[k];
			}
			cout << ans[0] << " " << ans[1] << " " << ans[2] << " " << ans[3] << endl;
		}
	}
	return 0;
}