import std.stdio : write, writeln;
import std.array;
import std.range;
import std.typecons;
import std.bigint;
import std.algorithm;

void main(){
	int n = next!int;
	
	int[4][4] tab;
	for( int i = 0; i < 4; ++i ){
		for( int j = 0; j < 4; ++j ){
			tab[ i ][ j ] = i%2==0 ? (i + j)%4 : ( i - j + 4 )%4;
		}
	}
	int[4][4] vec = [
		[ 1, 1, 1, 1 ],
		[ 1, -1, 1, -1 ],
		[ 1, -1, -1, 1 ],
		[ 1, 1, -1, -1 ]
	];
	
	foreach(i; n.iota){
		int[4] a;
		foreach( ref v; a ) v = next!int;
		int[4] b;
		foreach( ref v; b ) v = next!int;
		
		int[4] res;
		for( int y = 0; y < 4; ++y ){
			for( int x = 0; x < 4; ++x ){
				res[ tab[ y ][ x ] ] += a[ y ] * b[ x ] * vec[ y ][ x ];
			}
		}
		
		for( int j = 0; j < 4; ++j ){
			if( j ) write = " ";
			write = res[ j ];
		}
		write = "\n";
	}
	
	assert( next!int == 0 );
}

import std.stdio : readln;
import std.conv : to;
import std.string : split, chomp;
import std.traits;
string[] input;
string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

T next( T : char )()
in
{
	assert(hasNext());
}
out
{
	input.front.popFront;
}
body
{
	return input.front.front.to!T;
}



bool hasNext(){
	if(input.length > 0){
		if(input.front.length == 0){
			input.popFront;
			return hasNext;
		}
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return hasNext;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}