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

int main(){
  int n;
  while(std::cin >> n){
    if(n == 0) break;
    for (int loop = 0; loop < n; loop++) {
      vector<int> a(4), b(4);
      for (int i = 0; i < 4; i++) std::cin >> a[i];
      for (int i = 0; i < 4; i++) std::cin >> b[i];

      vector<int> c(4, 0);
      vector<vector<int> > to = {
                                 {0, 1, 2, 3},
                                 {1, 0, 3, 2},
                                 {2, 3, 0, 1},
                                 {3, 2, 1, 0}
      };
      vector<vector<int> > val = {
                                  {1, 1, 1, 1},
                                  {1, -1, 1, -1},
                                  {1, -1, -1, 1},
                                  {1, 1, -1, -1}
      };
      for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 4; j++) {
          c[to[i][j]] += a[i]*b[j]*val[i][j];
        }
      }
      for (int i = 0; i < 4; i++) {
        std::cout << c[i];
        if(i != 3) std::cout << " ";
        else std::cout << std::endl;
      }
    }
  }
  return 0;
}

